This is a simple workaround regarding an error which happened to me today when running db migration in Rails 3. I have Rails 3.2.2 and MySQL 0.3.11. I was trying to run
bundle exec rake db:migrate
to create a table in database. I got this error
rake aborted! Can't connect to MySQL server on 'localhost' (10061) Tasks: TOP => db:migrate (See full trace by running task with --trace)
My simple work around was going to config/database.yml file and changing the host to use 127.0.0.1 instead of localhost as follows.
development: adapter: mysql2 encoding: utf8 reconnect: false database: quiz_development pool: 5 username: root password: host: 127.0.0.1











Hi Samuel,
Changing localhost to port number worked for we as well. But I am bit surprised here that localhost has also/run on the same port, then why I had to define the IP Address instead of localhost.
- Puneet
Punnet,
I am not quite sure why the case but out of trial and error I manage to solve the error. I ll investigate on the issue and post on the same. Thats a good note.
Thanks
Samuel
Worked for me as well. Thanks.
Why does this work?
Man, u save my life.
I was trying a lot of things, but not thinking in do that (127.0.0.1). The mysql workbench uses localhost, other applications also uses localhost. I tried to use localhost, LAN IP, LAN dns name and nothing had worked.
Well, now is working fine. Thank u a lot.
WOW! Just learning Rails, mySQL. Always “Can’t connect to mySQL…” thought I would never connect and get past this point. This worked. After 8 hours stuck,I have a long way to go but I am on my way again! Thanks.
thanks alot . it worked for me
Brilliant. Another satisfied customer here.
Man, I spent a lot of time on this … but nothing worked !
Your trick worked so well… thanks
Thanks a lot. I was stucked whith this error and U saved my life
Hello guys, please am trying to create a table using
db:migrate
but i keep getting this error message
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
126: The specified module could not be found. – C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so
#tho the file mysql_api.so exist there
Tasks: TOP => db:migrate
(See full trace by running task with –trace)
Please what can i do
Thanks it helped.
Fantastic. It worked for me.
Thanks a lot.
It worked for me
Thanks a lot:)
You can add next row at file C:\Windows\System32\drivers\etc\hosts:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
In this case you should change ‘localhost’ alias to direct ip address
Konstantin. Yah, thats works also.
Worked for me as well, but i would be interested in why it works o0. Is it possible that this is related to localhost being resolved as ::1: on newer machines with IPv6 enabled? Only an idea, blame me if i’m totally wrong here.
Thanks!
thank you very much!
if this type problem exist then open task manager and go to services and start my sql
services.