[SOLUTION] No such file or directory – /tmp/mysql.sock
[January 5th, 2006, Semarang, Central Java, Indonesia]
Debian :
/var/run/mysqld/mysqld.sock
Mac OS X XAMPP :
/Applications/xampp/xamppfiles/var/mysql/mysql.sock
Fedora (rpm) :
/var/lib/mysql/mysql.sock
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 ... development: ... 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 development: ... 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!