Today we had some problems with one of our Mysql database server. While doing mysql restart we could see the following errors in the .err log file located under /var/lib/mysql folder.
090817 1:58:19 [ERROR] Can’t start server : Bind on unix socket: Permission denied
090817 1:58:19 [ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?
090817 1:58:19 [ERROR] Aborting
Doing a local mysql connect on the server also reports the following error.
Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
The error is quite simple the only issue is with the socket as mysql daemon is not able to create the socket file under the mysql directory because of some permission issues.
Solution.
Step.1) First make sure you delete the existing socket file using the rm command.
Code:
— rm /var/lib/mysql/mysql.sock
Step.2 ) Killall existing mysql processes via the following command.
Code:
— killall -e -9 mysql
Step.3) Very important , Make sure the permission for the mysql database directory under /var/lib/ folder should mysql:root
Code:
— chown mysql:root mysql
Step.4) With the above information you should be able to start mysql sucessfully and the socket file should be created successfully under the database directory.
Code:
— service mysql start
You need to verify your database path , some servers are having different database path for ex. /var/run/mysql folders.
I am sure with the above tips mysql server should not have any problems and it should be running good.