ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql/mysql.soc

Posted 七月逆流

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql/mysql.soc相关的知识,希望对你有一定的参考价值。

[[email protected] ~]# mysql -h localhost -uroot -p
Enter password:
ERROR 2002 (HY000): Cant connect to local MySQL server through socket /tmp/mysql/mysql.sock (2)


[[email protected] ~]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql/mysql.sock‘ (2)


换成

[[email protected] ~]# mysql -h 127.0.0.1 -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7812
Server version: 5.7.18-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql>

原因:MySQL设置成了值允许 127.0.0.1 地址访问

以上是关于ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql/mysql.soc的主要内容,如果未能解决你的问题,请参考以下文章

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' 。安装后出错

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) on Mac

FreeBSD ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/var/run/mysqld/mysqld.sock'

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when I

尝试了一切仍然得到 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (