好久不用虚拟机来测试系统了,闲置了好长一段时间之后,昨天发现虚拟机服务器端的数据库连不上了,用终端运行mysql命令提示:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
网上给了很多解决方案,比如修改/etc/my.cnf文件和软链接,可惜对我没用。
用终端查看服务的运行状态,提示:
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
网上找了一下,解决方案如下:
# rm /var/lock/subsys/mysql
# service mysql restart
OK,问题解决。
参考文章
MYSQL错误解决:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
MySQL is not running, but lock file的解决办法