#2002 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) — The server is not responding (or the local server's socket is not correctly configured).
因为使用源码编译安装的 mysql 5.7 的默认配置文件 /etc/mysql/my.cnf 没有 [client] 这一段配置.而默认的 mysql sock 位置为 /var/run/mysqld/mysqld.sock
首先找到所有的 socket 文件:
1 2 3 4 5
yzhang@coam:~$ sudo find / -type s /tmp/mongodb-27017.sock /tmp/mysql/mysql.sock /run/fail2ban/fail2ban.sock ...
所以手动 /etc/mysql/my.cnf 添加这一行:
1 2
[client] socket=/tmp/mysql/mysql.sock <= this path should be also same as is[mysqld]