Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决
Posted 抟九
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决相关的知识,希望对你有一定的参考价值。
安装上mysql后,报 Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘,试了网上的方法都没有用,于是打开/etc/my.cnf查看。
看到这么一段:
# The MySQL server
26 [mysqld]
27 port = 3306
28 socket = /tmp/mysql.sock
29 skip-external-locking
30 log-error=/alidata/log/mysql/error.log
31 key_buffer_size = 16M
32 max_allowed_packet = 1M
33 table_open_cache = 64
34 sort_buffer_size = 512K
35 net_buffer_length = 8K
36 read_buffer_size = 256K
37 read_rnd_buffer_size = 512K
38 myisam_sort_buffer_size = 8M
可知,使用的.sock文件,是/tmp/mysql.sock,而不是/var/run/mysqld/mysqld.sock,于是加个链接
ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock
解决
以上是关于Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决的主要内容,如果未能解决你的问题,请参考以下文章
MySQL Can't connect to MySQL server on 'localhost' (10061)
Jenkins: Can't connect to Docker daemon解决办法
MySQL错误2003:Can't connect to MySQL server (10060)
Can't connect to MySQL server on 'localhost'(10061)解决方法