ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

If you see this Error Dont fret...
For me the Error Looked like this on web page...
ERROR: Unable to connect to database: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) 0: /usr/local/psa/admin/auto_prepend/auth.php3:67 psaerror(string "Unable to connect to database: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)")
while on the putty
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Basically the reason is that the mysql.sock file is either empty or not there.Deleted by some cron jobs.

What we can do is check the path of mysql.sock file it should be same to what we have in php.in. One can check it thru phpinfo(); and look for
MYSQL_SOCKET /var/lib/mysql/mysql.sock

If Still we are getting the Error..
try to restart the Server..through the following command
/etc/rc.d/init.d/mysqld restart
This works 90% of time..

One can also try mysql_safe to restart Mysql in safe mode

If even after this it doesnt start check..
http://ftp.tas.gamepoint.com.au/pub/mysql/doc/mysql/en/Can_not_connect_to_server.html


Enjoy...

COUNTER