docker安装mysql,本地连接报错 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

今天用docker装mysql,连接时报这个错:

docker安装mysql,本地连接报错 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

 

 

 

首先排查mysql的my.cnf配置文件   打开/etc/my.cnf查看

docker安装mysql,本地连接报错 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

 

 

 

发现路径没毛病,然后去对应路径查看也有文件。说明配置无问题,然后尝试第二个解决方法

mysql -h 127.0.0.1 -u root -p

修改一下连接地址,改为127.1

然后。。连接成功。。

docker安装mysql,本地连接报错 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

 

 如果上面方法不行,这时候还有一种连接方法,指定端口试试

mysql -h 127.0.0.1 -P 3306 -u root -p

  

docker安装mysql,本地连接报错 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

上一篇:PS制作逼真的下雨效果图


下一篇:Photoshop 一张简洁的新年贺卡制作方法