Mysql error :- ERROR! MySQL is not running, but lock exists root@server


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 doesnt  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 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

 

 

 

Advertisements

One thought on “Mysql error :- ERROR! MySQL is not running, but lock exists root@server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s