rake aborted! No such file or directory - /tmp/mysql.sock

Posted by Ryan Baxter Sat, 06 Oct 2007 20:40:00 GMT

If you’re running into the above error message when trying to perform a Rails migration on Debian or Ubuntu then you might try adding the following line to your database.yml file:

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

My database.yml file looks sorta like this:

development:
  database: crunchlife_development
  adapter: mysql
  host: localhost
  username: mysql_user
  password: @!#?@!
  socket: /var/run/mysqld/mysqld.sock 

test:
  database: crunchlife_test
  adapter: mysql
  host: mysql.ryanbaxter.net
  username: mysql_user
  password: @!#?@!
  socket: /var/run/mysqld/mysqld.sock

production:
  database: crunchlife_production
  adapter: mysql
  host: mysql.ryanbaxter.net
  username: mysql_user
  password: @!#?@!

Good luck and happy migrations!

Comments

Leave a response

Avatar
George Comment_bubble 9 days later:
Thanks.. was looking for this fix. It works a treat on ubuntu 7.04.
Avatar
Ryan Baxter Comment_bubble 9 days later:
Huzzah! My blog helped somebody. :P
Avatar
andy Comment_bubble 22 days later:
Thanks - it helped me as well...
Avatar
Matthias (mw@zweiloewen.de) Comment_bubble 2 months later:
Yipiiiieeeeee, great! THX & greets from germany!
Avatar
Paul Fisher Comment_bubble 6 months later:
This is fantastic. You saved me from a bunch of headaches. Thanks!
Avatar
Ryan Baxter Comment_bubble 6 months later:
Great! I always like hearing when something I post helps someone out.
Avatar
Scott O Comment_bubble 9 months later:
Still helping people like me, Ryan. Thanks.
Avatar
Tyler Comment_bubble 9 months later:
You can also just symlink /tmp/mysql.sock to /var/run/mysqld/mysqld.sock
sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
I think that's a little DRYer solution to modifying each entry in your db.yml
Avatar
jannie Comment_bubble 10 months later:
Dankie!!
Avatar
Ryan Baxter Comment_bubble 10 months later:
Tyler - If you're developing and testing on the same server then it may be a teeny bit DRYer. I'm not so it's a irrelevant whether I create two symlinks or two config entries. Besides, I tend to forget symlinks between servers. If both entries are in your database.yml then you'll be less likely to forget a symlink migrating from dev to test.

Jannie - Welkom!
Avatar
namkhanh Comment_bubble 11 months later:
I used Ubuntu 8.0.4. I sort same upper but It display message "No such file or directory - /var/run/mysqld/mysqld.sock". please help me.
Avatar
Mark Comment_bubble 12 months later:
Woo hoo! Getting there now...