千家信息网

MySQL本地用IP登陆而非socket

发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,##想当然的指定hostname和端口。。。。失败[root@mysql01 ~]# /opt/mysql/bin/mysql -uroot -h localhost -P 3307 -pEnter
千家信息网最后更新 2024年09月22日MySQL本地用IP登陆而非socket

##想当然的指定hostname和端口。。。。失败
[root@mysql01 ~]# /opt/mysql/bin/mysql -uroot -h localhost -P 3307 -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

##正确方法,指定通信协议 --protocol tcp
[root@mysql01 ~]# /opt/mysql/bin/mysql -uroot -h localhost -P 3307 -p --protocol tcp
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.31-log Source distribution

Copyright (c) 2000, 2016, 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>

0