Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Atul picture Atul · Dec 15, 2010 · Viewed 815k times · Source

I am getting the following error when I try to connect to mysql:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Is there a solution for this error? What might be the reason behind it?

Answer

Jan Thomä picture Jan Thomä · Dec 15, 2010

Are you connecting to "localhost" or "127.0.0.1" ? I noticed that when you connect to "localhost" the socket connector is used, but when you connect to "127.0.0.1" the TCP/IP connector is used. You could try using "127.0.0.1" if the socket connector is not enabled/working.