• Register
3,890 points
11 5 1

If you are running in this error while trying to connect to a local MySQL Server then it means that your MYSQL server is not installed or the file does not exist in /var/lib/mysql/.


There are a couple of solutions for this error;

Check the status of MySQL:

First, check to see whether mysqld service is running or not. If not then start it:

service mysqld start

Then try to connect again.

Connect to

Try to connect to instead of localhost. Because when the user connects to the localhost, it will use a socket connector but if you connect to then TCP/ID connector will be used. So when the socket connector is not working then connect to instead.

Edit file my.cnf:

Find the file my.cnf to edit and add the following lines;


socket = /var/lib/mysql/mysql.sock


socket = /var/lib/mysql/mysql.sock

Restart mysql and try to connect again.


In some cases, mysql.sock can be located in another folder. You have to find it and symlink it. You can find it in /tmp/mysql.sock or /data/mysql_datadir/mysql.sock.


If the file is located in /tmp/mysql.sock

Then symlink it:

ln –s /var/lib/mysql.sock /tmp/mysql.sock

Restart mysql and try to connect again.

3,890 points
11 5 1