尝试连接到 mysql 并出现错误:不允许连接到此 MySQL 服务器连接被外部主机关闭
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11112555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
trying to connect to mysql and getting error :is not allowed to connect to this MySQL serverConnection closed by foreign host
提问by Maverick
Hi i am running two rhel instances in ec2. now i am trying to do $telnet ec2-184-73-58-163.compute-1.amazonaws.com 3306
嗨,我正在 ec2 中运行两个 rhel 实例。现在我正在尝试执行 $telnet ec2-184-73-58-163.compute-1.amazonaws.com 3306
Trying 10.193.139.147...
Connected to ec2-184-73-58-163.compute-1.amazonaws.com.
Escape character is '^]'.
bHost 'domU-12-31-39-05-3D-E6.compute-1.internal' is not allowed to connect to this MySQL serverConnection closed by foreign host.
I am a newbie. not getting what to do now? Please help.
我是新手。现在不知道该怎么办?请帮忙。
回答by Rakib
You cannot connect to the remote MySQL if you are not white listed in the MySQL user privileges table.
如果您不是 MySQL 用户权限表中的白名单,则无法连接到远程 MySQL。
Let's assume your IP address is 199.255.209.168
and you are trying to log into the MySQL daemon running at IP address 123.238.18.47
by the username rakman
with some password
让我们假设您的 IP 地址是,199.255.209.168
并且您正在尝试123.238.18.47
通过用户名rakman
和一些密码登录在 IP 地址上运行的 MySQL 守护程序
$ mysql -h 123.238.18.47 -u rakman -p
Enter password:
ERROR 1130 (HY000): Host '199.255.209.168' is not allowed to connect to this MySQL server
A mysql user [rakman]@[your IP address] needs to be present in the user privileges of MySQL running at 123.238.18.47
. So [email protected]
(or rakman@%
which will allow logging in to this MySQL from ANY remote host but is not recommended) needs to be present in the user privileges of MySQL running at 123.238.18.47
.
mysql 用户 [rakman]@[您的 IP 地址] 需要出现在运行于 的 MySQL 的用户权限中123.238.18.47
。所以[email protected]
(或者rakman@%
允许从任何远程主机登录到这个 MySQL 但不推荐)需要存在于运行在123.238.18.47
.
For the MySQL commands on how to achieve this, you can see the accepted answer at Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server. If you try to login after that.
有关如何实现此目的的 MySQL 命令,您可以在Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server 上看到接受的答案。如果您在此之后尝试登录。
$ mysql -h 123.238.18.47 -u rakman -p
Enter password:
Welcome to the MySQL monitor.
回答by Bipin
You have to give access permission on mysql
您必须授予对 mysql 的访问权限
for all ips use below
对于下面的所有 ips 使用
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' WITH GRANT OPTION;
for particular ip use below
对于下面的特定 ip 使用
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'youripaddres' WITH GRANT OPTION;
Thanks Bipin Bahuguna
感谢 Bipin Bahuguna
回答by James
I am also not that good in this area but i think this link can help you a little. This was my reference when i was having trouble with MySQL.
我在这方面也不是很好,但我认为这个链接可以帮助你一点。这是我在使用 MySQL 时遇到问题时的参考。
just try. I hope it works. SourceForge.net
你试一试。我希望它有效。 SourceForge.net