yyxianren

在连接mysql的时,经常会出现以下错误提示:

ERROR 2002 (HY000): Can\'t connect to local MySQL server through socket \'/var/lib/mysql/mysql.sock\'

 

出现此错误提示的原因一般有俩个:

一、mysql服务为启动

  该sock文件是mysql启动的时候创建的,弱服务关闭,该文件消失。

  判断mysql是否正常启动有俩个方法:

  方法一:

[root@localhost ~]# ps -ef | grep mysql
101      17285 16922  0 Apr04 pts/1    00:36:51 /usr/bin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-output=none --pid-file=/var/lib/mysql/mysqld.pid --port=3306 --console
root     25314 25296  0 22:50 pts/0    00:00:00 grep --color=auto mysql

  方法二:

[root@localhost ~]# netstat -ntlp | grep 3306

二、socket文件路径配置错误

  该问题一般是由于修改mysql的配置文件my.conf导致,查找文件中socket参数,修改正确即可;

分类:

技术点:

相关文章:

  • 2021-12-06
  • 2022-02-08
  • 2021-08-06
  • 2022-02-11
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
猜你喜欢
  • 2021-12-03
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
相关资源
相似解决方案