Can’t connect to local MySQL server through socket /tmp/mysql.sock , this issue is related to server used by MySQL to put in place the connection. Most of time you can face this problem in localhost environment that makes use of sockets. Let’s explain two kind of different solutions. First you need to check that your server is up and running. In Linux you can run:
ps xa | grep mysqld
and Windows OS, using the shell positioned in the socket file folder :
mysqladmin version
If you get an user error set the “-p” flag so you can enter your password. You should than see something like that:
Server version 5.0.51a-3ubuntu5.8Protocol version 10Connection Localhost via UNIX socketUNIX socket /var/run/mysqld/mysqld.sockUptime: 157 days 20 hours 10 min 40 sec
As you can see the folder socket is different than /tmp/mysql.sock. Now you can solve the issue by using a sym link :
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
or you can modify the configuration file my.cnf inserting the right path in the right section [client]
[client]port = 3306socket = /var/run/mysqld/mysqld.sock
Personally I found more useful the sym link solution.