登陆mysql时提示异常的解决方法

[root@host2 ~]# mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@host2 ~]#  /etc/init.d/mysql status
 ERROR! MySQL is running but PID file could not be found

 

查看MYSQL进程:
ps aux | grep mysql
然后KILL进程
kill -9 pid1 pid2 …

[root@host2 ~]# ps aux | grep mysql
root      1813  0.0  0.0 108336    68 ?        S    Jul14   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/host2.pid
mysql     1918  0.0 19.5 1076608 197440 ?      Sl   Jul14   0:02 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/host2.err --pid-file=/var/lib/mysql/host2.pid
root      2982  0.0  0.0 103256   844 pts/3    S+   00:09   0:00 grep mysql
[root@host2 ~]# kill -9 1813 1918

再启动MYSQL
/etc/init.d/mysql start
检查mysql运行状态
/etc/init.d/mysql status

成功!

posted @ 2015-07-15 15:15  泽锦  阅读(304)  评论(0编辑  收藏  举报