0
votes

Please help to solve this error

PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in lock_may_be_available() (line 167 of /var/www/ambu0/data/www/ambu_new/includes/lock.inc).

When I restart server, this error is comming

[root@vm3547 etc]# cd rc.d/init.d [root@vm3547 init.d]# mysql restart ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

2
Looks like your mysql-server is not running.Jens
yes so how should i solve itRahul lodhi
When do i restart server.this error is comming . [root@vm3547 etc]# cd rc.d/init.d [root@vm3547 init.d]# mysql restart ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)Rahul lodhi

2 Answers

0
votes

It seems that you have an existing /var/lib/mysql/mysql.sock file from one of the previous terminated runs. "restart" (as opposed to "start") means "try stopping and starting again". As there is a socket file in place, it tries to stop an instance on that port - and fails, as there is nothing there running.

Delete the invalid file.

-1
votes

Try to stop your mysql server and restart it again.

/etc/init.d/mysql  stop
/etc/init.d/mysql  start

Still same issue then rename mysql.sock file from mysql directory folder and restart mysql server.