ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
本地登陆mysql提示
[root@iZ23un4eyxhZ default]# mysql -i 127.0.0.1 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决方法:
由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,但linux系统总是去/tmp/mysql.sock查找,所以会报错,所以查找到正确的位置:
[root@iZ23un4eyxhZ default]# find / -name "mysql.sock" /tmp/systemd-private-9b22543919a542fe83203e70d30920d2-vpn.service-vhaYd1/tmp/mysql.sock
方法一:直接指定mysql通道
[root@iZ23un4eyxhZ default]# mysql --socket=/tmp/systemd-private-9b22543919a542fe83203e70d30920d2-vpn.service-vhaYd1/tmp/mysql.sock Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 2 to server version: 5.0.22 Type 'help;' or '/h' for help. Type '/c' to clear the buffer. mysql>
方法二:创建符号连接:
#为mysql.sock增加软连接(相当于windows中的快捷方式)。 ln -s /tmp/systemd-private-9b22543919a542fe83203e70d30920d2-vpn.service-vhaYd1/tmp/mysql.sock /tmp/mysql.sock
[root@iZ23un4eyxhZ default]# ln -s /tmp/systemd-private-9b22543919a542fe83203e70d30920d2-vpn.service-vhaYd1/tmp/mysql.sock /tmp/mysql.sock [root@iZ23un4eyxhZ default]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 2 to server version: 5.0.22 Type 'help;' or '/h' for help. Type '/c' to clear the buffer. mysql>
© 著作权归作者所有
下一篇: 防止搜索引擎收录网站
文章评论(0)