【发布时间】:2013-10-06 17:32:27
【问题描述】:
为什么我连接不上mysql?
mysql -u root -ptest101 -h xxx.xxx.xxx.xxx
ERROR 1130 (HY000): Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server
在 my.cnf 我有以下内容
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
我也跑了下面...
'UPDATE mysql.user SET Password = PASSWORD('test101') WHERE User = 'root';
FLUSH PRIVILEGES;
我可以在主机上使用 mysql -u root -ptest101 访问,但不能使用 mysql -u root -ptest101 -h xxx.xxx.xxx.xxx
哇...为什么会这样?我是 ubuntj 12.04
mysql> SELECT host FROM mysql.user WHERE User = 'root';
+---------------------------------------------+
| host |
+---------------------------------------------+
| % |
| 127.0.0.1 |
| ::1 | |
| localhost |
+---------------------------------------------+
5 rows in set (0.00 sec)
【问题讨论】:
-
请记住,mysql 帐户不仅仅是用户名。它们是
user@host对,其中任何一对都可以是通配符。您可能使用了正确的用户名,但您是否也授予了正确的主机权限?