您的位置:首页 > 教育 > 锐评 > MySQL报ERROR 2002 (HY000)解决

MySQL报ERROR 2002 (HY000)解决

2024/10/31 9:51:07 来源:https://blog.csdn.net/weixin_47139678/article/details/139415705  浏览:    关键词:MySQL报ERROR 2002 (HY000)解决

今天在连接客户服务器时MySQL的时候报:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql/mysql.sock’ (2)
在这里插入图片描述
[root@XXX ~]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql/mysql.sock’ (2)

解决方案:

在登录MySQL数据库的时候用一下命令

mysql -h 127.0.0.1 -uroot -p

[root@XXX ~]# 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 © 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>

在这里插入图片描述
完美解决!

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com