当试图连接到本地主机上3306端口上运行的MySQL数据库时(使用命令行工具mysql),我得到了错误:
错误2002 (HY000):无法通过套接字'/tmp/mysql.sock‘连接到本地MySQL服务器(2)
下面是我使用的命令:
> mysql -h localhost -P 3306
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)指定用户和密码也不起作用:
> mysql -h localhost -P 3306 -u dbuser -p
Password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)当我指定主机和端口时,为什么它试图使用UNIX套接字文件(就像在这里所做的那样)?
发布于 2017-04-12 12:03:20
您需要使用127.0.0.1而不是localhost:
> mysql -h 127.0.0.1 -P 3306
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8347701
Server version: 5.6.35-80.0-log Percona Server (GPL), Release 80.0,
Revision f113994f31
...你加入了!
https://serverfault.com/questions/844103
复制相似问题