[SOLUTION] No such file or directory – /tmp/mysql.sock

Posted: January 5, 2006 in Ruby on Rails

[January 5th, 2006, Semarang, Central Java, Indonesia]

Debian :




Fedora (rpm) :


sumber dari http://dev.rubyonrails.com dulu pernah dapet, males aja search lagi.

UPDATE (April 12, 2008, Kuala Lumpur, Malaysia)

Right now I always use Leopard for Development Environment, I also often use MySQL. when we generate rails project then it’ll be automatically by default set it to support sqlite3 as I believe we know that happened since not so long ago rails release, so when we generate rails project -d mysql then it’ll automatically set the default config/database.yml to support MySql including its path to mysql sock. Let’s see my copy paste below:

m:Desktop arie$ rails testing -d mysql && cd testing && cat config/database.yml
  socket: /opt/local/var/run/mysql5/mysqld.sock

Notice the socket. /opt/local/var/run/mysql5/mysqld.sock

Now let’s take a look at database.yml file that’s been generated automatically on my ubuntu box.

~/Documents/testing-ubuntu$ cat config/database.yml 
  socket: /var/run/mysqld/mysqld.sock

You see the difference? Look at the different socket, now it’s /var/run/mysqld/mysqld.sock

We usually use config/database.example.yml as a template/example one so that our users can copy paste it to their own config/database.yml in their working copy. So they’re free to set it based on what socket they got.

Feel free to leave your comments if you got anything to ask me, I’ll answer as soon as possible if I can answer it.

UPDATE Aug 5th, 2009 @ Indonesia

I once experienced Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ on my new macbook pro 13 inch using leopard 10.5.7, then I changed the socket to /tmp/mysql.sock then it worked!


tinggalkan feedback konstruktif atau lebih baik diam

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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