标题:[Linux下]解决MySQL不能通过mysql.sock连接的问题 出处:Felix021 时间:Sun, 09 Dec 2007 20:26:43 +0000 作者:felix021 地址:https://www.felix021.com/blog/read.php?488 内容: 解决MySQL不能通过mysql.sock连接的问题 情况如下: [root@localhost opt]# mysql -uroot -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 解决办法: [root@localhost opt]#cat /etc/my.cnf 查看 "socket="后面的字符串。 默认应该是/tmp/mysql/mysql.sock 比如被修改为是 /tmp/mysql.sock 那么这样就可以连接了: [root@localhost opt]# mysql --socket=/tmp/my.cnf -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4521 to server version: 5.0.18-standard Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> Generated by Bo-blog 2.1.0