Can't connect to local MySQL server through socket
11:09 pm on Mar 9, 2011 (gmt 0)
Hi all !
I'm running a vbulletin forum for 10 years now. Suddently, i started to get problems with MySQL, getting tons of emails giving this error:
mysql_pconnect() [<a href='function.mysql-pconnect'>function.mysql-pconnect</a>]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Anyway to fix this permanently ? don't know what to do....
8:06 pm on Mar 10, 2011 (gmt 0)
Did you check if the file /var/lib/mysql/mysql.sock exists? List the directory with the following command:
ls -ladF /var/lib/mysql/mysql*
The result should be this:
drwx------ 2 mysql mysql 4096 Apr 4 2010 mysql/ srwxrwxrwx 1 mysql mysql 0 Jan 7 00:16 mysql.sock=
Sometimes the mysql.sock doesn't exist because it has been erased accidentaly, and sometimes it is not a socket but a normal file. In that case the = is missing at the end of the file name with this specific directory listing command. If it is a file, deleting that file and restarting the MySQL server should do the trick.
You should also check if there has been a recent update of MySQL on your server which changed your my.cnf file. That file should at least contain the following lines: