主机'xxx.xx.xxx.xxx'不允许连接到该MySQL服务器 [英] Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

查看:98
本文介绍了主机'xxx.xx.xxx.xxx'不允许连接到该MySQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是非常简单的,但是我 无法使它在我的生命中发挥作用.
我只是想远程连接到我的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:

如果您不知道为什么会得到 访问被拒绝,从用户中删除 列出所有具有主机的条目 包含通配符的值(条目 包含%"或"_"字符的字符).一种 非常常见的错误是插入新的 主机='%'的条目,并且 User ='some_user',认为这 允许您将localhost指定为 从同一台机器连接.这 之所以不起作用的原因是 默认权限包括 Host ='localhost'的条目,并且 用户=''因为该条目有一个主机 值'localhost'更大 比%"更具体,它用于 在以下情况下对新条目的偏好 从本地主机连接!正确的 程序是插入第二个条目 使用Host ='localhost'和 User ='some_user',或删除 Host ='localhost'的条目,并且 用户=''删除条目后, 记得要签发FLASHH PRIVILEGES 重新加载授权表的语句. 另请参见第5.4.4节访问 控制,阶段1:连接 验证".

If you cannot figure out why you get Access denied, remove from the user table all entries that have Host values containing wildcards (entries that contain '%' or '_' characters). A very common error is to insert a new entry with Host='%' and User='some_user', thinking that this allows you to specify localhost to connect from the same machine. The reason that this does not work is that the default privileges include an entry with Host='localhost' and User=''. Because that entry has a Host value 'localhost' that is more specific than '%', it is used in preference to the new entry when connecting from localhost! The correct procedure is to insert a second entry with Host='localhost' and User='some_user', or to delete the entry with Host='localhost' and User=''. After deleting the entry, remember to issue a FLUSH PRIVILEGES statement to reload the grant tables. See also Section 5.4.4, "Access Control, Stage 1: Connection Verification".

这篇关于主机'xxx.xx.xxx.xxx'不允许连接到该MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆