[email protected]
存在,但仍然无法连接到本地 MySQL。看起来 MySQL 验证的是主机名,而不是本地 ip(127.0.0.1)。
root@castle /v/l/mysql# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.6.22 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, 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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user, host from user where user='root';
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| root | castle |
| root | localhost |
+------+-----------+
4 rows in set (0.00 sec)
mysql> exit;
Bye
root@castle /v/l/mysql# mysql -u root -h 127.0.0.1
ERROR 1045 (28000): Access denied for user 'root'@'lixxx-yyy.members.linode.com' (using password: NO)
答案1
“lixxx-yyy.members.linode.com”从哪里来的?检查你的 /etc/hosts 文件。
尝试:
host 127.0.0.1
期望看到:
1.0.0.127.in-addr.arpa domain name pointer localhost.
您可以将该主机添加到主机表以允许 root 连接,或者尝试将“127.0.0.1”按预期解析为“localhost”。