为什么我得到“MySQL 没有运行但锁存在”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1248433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:49:33  来源:igfitidea点击:

Why do I get "MySQL is not running but lock exists"?

mysqllocking

提问by MySQL DBA

I am getting this error

我收到此错误

mysql is not running but lock exist

mysql 没有运行但锁存在

when I am checking the status of MySQL server. I have removed the lock files using following command:

当我检查 MySQL 服务器的状态时。我已经使用以下命令删除了锁定文件:

rm /var/lock/subsys/mysql

but still I am getting same error.

但我仍然遇到同样的错误。

Can anyone provide any input on this.

任何人都可以就此提供任何意见。

回答by Charles Ma

try using the unix lsof command to see which program has the lock

尝试使用 unix lsof 命令查看哪个程序有锁

lsof | grep mysql

EDIT:in fact, run lsof on the lock itself

编辑:事实上,在锁本身上运行 lsof

lsof /var/lock/subsys/mysql

回答by Nauman

For this similar error:

对于这个类似的错误:

service mysql status ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists

服务 mysql 状态错误!MySQL 没有运行,但锁文件 (/var/lock/subsys/mysql) 存在

Follow these steps:

按着这些次序:

  1. rm /var/lock/subsys/mysql rm:

    remove regular empty file /var/lock/subsys/mysql? y

    Press y

  2. /etc/init.d/mysql start.

    If the error occurs again after starting MYSQL then execute ps -ef | grep mysql

  3. Kill all processes of MySQL and repeat steps 1& 2.

  1. rm /var/lock/subsys/mysql rm

    删除常规的空文件/var/lock/subsys/mysql?是

    y

  2. /etc/init.d/mysql start.

    如果启动MYSQL后再次出现错误则执行 ps -ef | grep mysql

  3. 杀死 MySQL 的所有进程并重复步骤12

回答by muharrem.eke

I had the same error. It started after an unexpected server reboot. I saw there is a default /etc/my.cnf file which is not in use for my installation. The issue resolved when it renamed my.cnf as my.cnf_old

我有同样的错误。它在意外的服务器重启后启动。我看到有一个默认的 /etc/my.cnf 文件没有用于我的安装。将 my.cnf 重命名为 my.cnf_old 后问题解决