问题描述
这应该是非常简单的,但是我 无法使它在我的生命中发挥作用.
我只是想远程连接到我的MySQL服务器.
This should be dead simple, but I cannot get it to work for the life of me.
I'm just trying to connect remotely to my MySQL server.
连接为
mysql -u root -h localhost -p
工作正常,但尝试
mysql -u root -h 'any ip address here' -p
失败,并显示错误
ERROR 1130 (00000): Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server
在mysql.user
表中,具有主机"localhost"的用户"root"和具有主机%"的另一个用户的条目完全相同.
In the mysql.user
table, there is exactly the same entry for user 'root' with host 'localhost' as another with host '%'.
我不知所措,不知道如何进行.任何想法都欢迎.
I'm at my wits' end, and have no idea how to proceed.Any ideas are welcome.
推荐答案
可能是安全预防措施.您可以尝试添加新的管理员帐户:
Possibly a security precaution. You could try adding a new administrator account:
mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> WITH GRANT OPTION;
尽管正如Pascal和其他人指出的那样,让具有这种访问权限的用户可以访问任何IP并不是一个好主意.如果需要管理用户,请使用root,并将其保留在localhost上.对于其他任何操作,请准确指定所需的特权,并按照Pascal的建议限制用户的可访问性.
Although as Pascal and others have noted it's not a great idea to have a user with this kind of access open to any IP. If you need an administrative user, use root, and leave it on localhost. For any other action specify exactly the privileges you need and limit the accessibility of the user as Pascal has suggest below.
从MySQL常见问题解答中:
From the MySQL FAQ:
这篇关于主机'xxx.xx.xxx.xxx'不允许连接到该MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!