MySQL: mysql is not running but lock exists solution

  • 2020-05-09 19:24:51
  • OfStack

Error starting MySQL, check the down state, find prompt MySQL is not running,but lock exists:

One user said it might have something to do with the log file, so he removed the log file and restarted MySQL, finally OK

After looking for the information, they basically said:

 
# chown -R mysql:mysql /var/lib/mysql 
# rm /var/lock/subsys/mysql 
# service mysql restart 


After executing the discovery, it is the same prompt.

Since it is on the cPanel server, the following command is used:

 
# yum remove mysql mysql-server 


Uninstall mysql and reinstall:

 
# /scripts/mysqlup  � force 


After loading, it was found that there was still an error in rebooting. After a careful look, it was found that the pid file was not named after the current host name, so it was executed:

 
# echo `ps aux | grep mysql | grep  " user=mysql "  | grep -v  " grep "  | awk  ' {print $2}'`>> hostname.pid 

The following pid file was regenerated, and owner and group were modified to mysql:

 
# chown mysql:mysql hostname.pid 


Error saving and restarting later.

Finally, I found a netizen who said it might be related to log file, so I removed the log file and restarted MySQL, finally OK.

A MySQL crash on Red Hat system resulted with:

/etc/init.d/mysql status

coming back with:

mysql is not running but lock exists


Solved by removing the lock file:

rm /var/lock/subsys/mysql


If this happens again it may also be necessary to remove the pid file from /var/lib/mysql

Related articles: