Mysql is not running on the server. when I try to connect to mysql I get the following error :-

root@server [~]# mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
root@server [~]# /etc/init.d/mysql status
ERROR! MySQL is not running, but lock exists
root@server [~]#

When checked with the MySQL service I got this error

root@server [~]# /etc/init.d/mysql status
ERROR! MySQL is not running, but lock exists
root@server [~]#

Here are the steps that should fix the issue.

root@server [~]# rm /var/lock/subsys/mysql
rm: remove regular empty file `/var/lock/subsys/mysql’? y

root@server [~]# /etc/init.d/mysql start

If still, it doesn’t solve the issue, The best possibility is that the MySQL PID file was left after the system restart and I assume that MySQL server was not stopped properly.

So please check MySQL by the following command

root@server [~]# top |grep mysql
OR
root@server [~]# ps aufx | grep mysql

If it shows the MySQL process, Kill that mysql process and again run the command:

root@server [~]# rm /var/lock/subsys/mysql

and start the MySQL service by

root@server [~]# /etc/init.d/mysql start

This should resolve the issue

# Note: There could be some chances that your disk usage 100% full.

root@server [~]# df -h

If that one is usr, var or tmp then you can remove old logs.

Hope you Enjoy!

  1. thanks problem solved. i used ($ rm /var/lock/subsys/mysql )

    • Yogesh says:

      Hi , I tried the above step but it still does not work,.. same error ..
      any other fixes ..

      the main fault is that i am unable to start the service at all.
      the error message is as follows:
      root@localhost ~]# service mysql.server start Starting MySQL….. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid). [root@localhost ~]# service mysql start Starting MySQL…. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).

  2. TechGrah Consulting says:

    I have done everything mentioned in the post, but mysql server is still not getting start.