很奇怪,当我用 “/root/lnmp status”命令查询mysql状态时,出现了一个错误提示: ERROR! MySQL is running but PID file could not be found。好像有问题啊!不过网站是运行正常的,它自己也说了“MySQL is running”。

  网上搜索方法,第一个原因有人说可能是磁盘满了,马上用“df -h”查看磁盘使用情况,结果发现正常,空得很!第二个解决方法来了!ps aux |grep mysq* 查看MySQL进程,如下:

[root@HQW-aliyun ~]# ps aux |grep mysq*
root 11791 0.0 0.0 106228 964 pts/1 S 2014 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/AY140721135729266d0fZ.pid
mysql 16908 1.0 4.3 812412 44648 pts/1 Sl 17:46 0:41 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/var/AY140721135729266d0fZ.err --pid-file=/usr/local/mysql/var/AY140721135729266d0fZ.pid --socket=/tmp/mysql.sock --port=3306
root 19142 0.0 0.0 103184 872 pts/0 S+ 18:55 0:00 grep mysq*

如果看到上面的内容,那说明MySQL的进程已经卡死了,这时就要把这些卡死的进程结束掉。这两个进程是上面的11791和16908,用 kill 命令咯!结果真的好了!!!全过程执行记录如下:

[root@HQW-aliyun ~]# /root/lnmp status
=========================================================================
Manager for LNMP V1.1 , Written by Licess
=========================================================================
LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux
This script is a tool to Manage status of lnmp
For more information please visit http://www.lnmp.org

Usage: /root/lnmp {start|stop|reload|restart|kill|status}
=========================================================================
nginx (pid 24147 7651) is running...
php-fpm is runing!
ERROR! MySQL is running but PID file could not be found
[root@HQW-aliyun ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 12G 7.2G 62% /
tmpfs 498M 0 498M 0% /dev/shm
/dev/xvdb1 30G 413M 28G 2% /home/wwwroot
[root@HQW-aliyun ~]# ps aux |grep mysq*
root 11791 0.0 0.0 106228 964 pts/1 S 2014 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/AY140721135729266d0fZ.pid
mysql 16908 1.0 4.3 812412 44648 pts/1 Sl 17:46 0:41 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/var/AY140721135729266d0fZ.err --pid-file=/usr/local/mysql/var/AY140721135729266d0fZ.pid --socket=/tmp/mysql.sock --port=3306
root 19142 0.0 0.0 103184 872 pts/0 S+ 18:55 0:00 grep mysq*
[root@HQW-aliyun ~]# kill 11791
[root@HQW-aliyun ~]# kill 16908
[root@HQW-aliyun ~]# service mysql start
Starting MySQL.. SUCCESS!
[root@HQW-aliyun ~]# /root/lnmp status
=========================================================================
Manager for LNMP V1.1 , Written by Licess
=========================================================================
LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux
This script is a tool to Manage status of lnmp
For more information please visit http://www.lnmp.org

Usage: /root/lnmp {start|stop|reload|restart|kill|status}
=========================================================================
nginx (pid 24147 7651) is running...
php-fpm is runing!
SUCCESS! MySQL running (19568)
[root@HQW-aliyun ~]#