启动MySQL出错,查看了下状态,发现提示MySQL is not running,but lock exists:
一个网友说可能和log文件有关,于是将log文件给移除了,再重启MySQL终于OK了
找了下资料,基本上都是说:
# chown -R mysql:mysql /var/lib/mysql
# rm /var/lock/subsys/mysql
# service mysql restart
执行完发现还是这个提示。
因为是在cPanel服务器上,所以又通过命令:
# yum remove mysql mysql-server
将mysql卸载了,然后重新安装:
# /scripts/mysqlup ?force
装好之后发现重启还是出错,又认真看了下,发现pid文件不是以当前的主机名命名的,于是执行:
# echo `ps aux | grep mysql | grep “user=mysql” | grep -v “grep” | awk ‘{print $2}'`>> hostname.pid
重新生成了下pid文件,同时修改owner和group为mysql:
# chown mysql:mysql hostname.pid
之后保存再重启还是出错。
最后查到一个网友说可能和log文件有关,于是将log文件给移除了,再重启MySQL终于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