rake aborted: no such file to load mysql

Programmers who work mostly on windows have seen this kind of errors many times.. as a windows programmer I have been through many sites and collect d relevant data, now I am showing it to you..

The errors which might come to you something like this:
no such file to load mysql
rake aborted: no such file to load mysql
The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql
Could not find RubyGem rake-compiler (~> 0.5)

To solve such problems follow these steps:
Step 1. Update rubygems to the latest version(like I upgraded it to 1.3.5).
Step 2: install rake-compiler(by gem install rake-compiler).
Step 3: if already installed hoe gem update it(gem update hoe) or install a fresh one.
Step 4: Download libMySQL.dll from here and copy it into C:/ruby/bin or wherever your ruby is installed, but make sure it should be in bin directory.
Step 5: Stop the mysql service, from Control Panel -> Administrative tools -> services -> mysql, and then restart it.

That’s it. You are done, after all these steps you can try
rake db:migrate
Suppose if that doesn’t work then after 4th step, stop the mysql service and restart your system.

I welcome all of you to post your comments, feedbacks, queries

Puneet Pandey


21 thoughts on “rake aborted: no such file to load mysql

  1. adl October 12, 2009 / 12:32 AM

    i did what you say i am reciving this message when i do rake db:migrate
    how can i fix this
    rake aborted!
    no such file to load –sqlite3
    see full trace by runing task with –trace

    each time i try to run my application i recive the avove mesge then when i ignore it i put ruby script/server
    i open just hte first page then errors

  2. Puneet Pandey October 12, 2009 / 6:39 AM

    All you need to do is to install sqlite3 gem by typing:
    gem install sqlite3 in command prompt. and you are getting this error coz your application has sqlite3 settings stored in config/database.yml

    If you want to use mysql then make sure whenever you are creating new applications it should have mysql database like:
    rails my_app –database=mysql

    In Your case all you need to do is to change the database.yml file like this:
    adapter: mysql
    encoding: utf8
    reconnect: false
    database: your_database_name
    pool: 5
    username: root
    password: your_mysql_pwd

    save it and restart your server. It should run, if you have mysql installed and its gem ‘mysql’

    Let me know if it works

    Puneet Pandey

    • adl October 12, 2009 / 9:16 AM


      thank you so much

      but still not working when i put gem install sqlite3 recive message says:
      ruby.exe:no such file to load –ubygems

      i tried in my other computer also recive diffrent message says:
      ERROR: could not find gem sqlite3 locally or in a repository.

      also i want to aske you about these steps cuz i have my sql in one of my computer:
      adapter: mysql
      encoding: utf8
      reconnect: false
      database: your_database_name
      pool: 5
      username: root
      password: your_mysql_pwd

      do not know where i supose to go to put these
      iam beginer in ruby in rails

      thank you

  3. Puneet Pandey October 12, 2009 / 9:24 AM

    I suggest you to download and read some pdf’s on ruby on rails.. your approach is wrong.. you’ve started programming directly which is wrong.. there are online tutorials, books which has some demo rails application.. google it and try it, It will guide you through all the steps…

  4. Ganesh Kathare December 1, 2009 / 8:18 AM

    Hi Puneet,

    I need help for following Mysql problem :

    \>> @slugs = Slug.all

    ActiveRecord::StatementInvalid: Mysql::Error: MySQL server has gone away: SELECT * FROM `slugs` from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log’ from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:320:in `execute’ from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:595:in `select’ from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache’ from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all’ from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:661:in `find_by_sql’ from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1553:in `find_every’ from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:615:in `find’ from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:635:in `all’ from (irb):6

    I don’t know how to resolve this problem.. !

    Basically facing this problem while I’m working on the ruby Console of myproject.

    After this error each time I have to reload console then only I can proceed further work..

    Not getting exactly why?

    I’m using Ruby 1.8.6, Rails – 2.3.2

    Thanks in advance..!
    🙂 🙂

  5. Ganesh Kathare December 1, 2009 / 8:23 AM

    Problem is :

    “Mysql::Error: MySQL server has gone away: ”

    getting this error only on ruby console..

    Any solution..?


  6. Puneet Pandey March 16, 2010 / 11:54 AM

    Sounds like a strange error to me…. I’ve never faced it before.. if you can provide me some more inputs about what exactly you’re trying to do.. may be we’ll be come up with some solution.\


    • Ganesh Kathare March 17, 2010 / 6:54 AM

      Hi Puneet,

      Thanks for ur reply..

      But I have resolved this issue..!

      I didnt find source(i.e origin) of this issue.. I think It might be due to some rails caching problem..

      After many trial I gone with following solution..

      module ActiveRecord::ConnectionAdapters
      class MysqlAdapter
      alias_method :execute_without_retry, :execute

      def execute(*args)
      rescue ActiveRecord::StatementInvalid => e
      if e.message =~ /server has gone away/i
      warn “Server timed out, retrying”
      raise e

      The above code is being used in rails configurations files..
      Issue has been actually resolved by using MysqlAdapter’s exception notifications..!

      Ganesh Kathare.
      (ROR-Developer) 🙂

  7. Pravin Parulekar April 1, 2010 / 6:51 AM

    If this mysql dll is so much essential, why is it not bundled with the gem?
    Thanks so much, my proble was solved after I kept this dll in the bin directory!!!

    • Puneet Pandey April 12, 2010 / 8:58 AM

      They have not configured this gem or I can say updated this gem(for windows).. so we have to do this manually.. but for most of the users, this must not be required.. for few cases we can follow 🙂


  8. ramu May 7, 2010 / 6:24 AM

    thank u so much!!!

  9. willa June 22, 2010 / 5:42 AM

    Hey I have noticed that you have given explanation for windows programmer. I am wondering whether I should use the same solution on ubuntu or there is another solution because I am facing the same problem when I issue command rake db:migrate.

    • Puneet Pandey June 23, 2010 / 8:13 AM

      I think you should give a try… but ignore the steps for mysql.dll file… I think its no more in use when you are dealing with Linux Environment and then let me know what are you getting..


  10. Armando June 25, 2010 / 8:04 AM

    thanks a lot! You were very helpful

  11. Sandino November 1, 2010 / 9:31 PM

    Thanks a lot for this solution.
    I tried with the same file wich come along with xampp in xampp/mysql and it did not work…this one made the trick!!!
    thanks again for sharing

  12. Sahin April 28, 2011 / 7:56 AM

    Have you used “Whenever” gem ?????

    • Puneet Pandey April 28, 2011 / 4:25 PM

      No, But I know it purpose… it is used for scheduling a task or a job at regular intervals.

      Do you need any help with regards to that?

      – Puneet

  13. John February 24, 2015 / 8:31 PM

    Is the link in step 4 still working? Its giving me an error to say the page isnt there.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s