MySQL报错的解决Can‘t connect to local MySQL server through socket ‘varlibmysqlmysql.soc

Posted 程序员超时空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL报错的解决Can‘t connect to local MySQL server through socket ‘varlibmysqlmysql.soc相关的知识,希望对你有一定的参考价值。

工具连接本地数据库报错Can’t connect to local mysql server through socket '/var/lib/mysql/mysql.soc

1:查看my.conf配置文件(确保mysql启动)

/etc/my.conf:

可以看到socket位置在/tmp/mysql.sock,不在/var/lib/mysql/mysql.soc

两种方法:1:修改配置文件。2:用软链接,

本人采用第二种方法:

1:在/var/lib下建mysql 文件sudo mkdir mysql

sudo mkdir mysql

2:用软链接关联两个文件——

ln -s 源文件名称 软链接文件名称
sudo ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

再一次连接,显示成功

报错:'Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’,原理和上面一样

以上是关于MySQL报错的解决Can‘t connect to local MySQL server through socket ‘varlibmysqlmysql.soc的主要内容,如果未能解决你的问题,请参考以下文章

Mysql问题:Can't connect to MySQL server on localhost (10061)解决方法

MySQL问题:2002 - Can‘t connect to server on ‘localhost‘(10061)已解决

用Navicat连接mysql报错:2003-Can't connect to MySql server on '10.100.0.109'(10039)

mysql报错ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

在Linux系统中登录MySQL报错“Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ “

Problemxampp in ubuntu下命令行启动mysql报错: ERROR 2002 (HY000): Can't connect to local MySQL server t(代