[root@localhost bk]# mysql -h127.0.0.1 -uroot -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
[root@localhost bk]# perror 111
OS error code 111: Connection refused
[root@localhost bk]#
#去掉ip地址能登录
[root@localhost bk]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.35-log MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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>
原因
--尝试下来,port问题,有可能本地的MySQL port不是默认3306,这样(mysql -h127.0.0.1 -