一、故障现象
登录Mysql数据库时出现ERROR 2002错误,具体描述如下:
# mysql -uroot -p12345
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
二、故障分析
--查看mysql实例的状态
# netstat -ntlp | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 114038/mysqld
--查看my.cnf关于socket的配置
# more /etc/my.cnf |grep sock
socket=/usr/local/mysql/mysql.sock
三、处理方法
--为socket文件建立链接方式
# ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock
参考链接:
https://www.jb51.net/article/56952.htm
https://www.cnblogs.com/yang1314/p/14505290.html