Sep 28, 2010

Mysql2 Error after upgrading an app to Rails 3

I was just updating the official Econify website to use Rails 3 and everything was working fine except for a problem with the mysql2 gem.  The error I was getting was


Mysql2::Error (Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)):

Now it didn't happen in development so I was perplexed until I realized that the rails upgrade plugin I used to help me along had replaced my database.yml file with a sane alternative.  Since I was developing on a mac it had possibly prepopulated both the database name and a default mysql.sock.  Correcting my database.yml file resolved the issue. 

If you deploy to ubuntu, the correct socket entry for your database.yml file is probably:


socket: /var/run/mysqld/mysqld.sock

It's amazing that no matter how far you get, you sometimes have to circle back and revisit the basics.

No comments:

Post a Comment