17

嗨,我在 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.

我是新手。现在不知道该怎么办?请帮忙。

4

3 回答 3

23

如果您不在 MySQL 用户权限表中的白名单中,您将无法连接到远程 MySQL。


假设您的 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

mysql 用户 [rakman]@[your IP address] 需要存在于运行于123.238.18.47. 因此rakman@199.255.209.168(或者rakman@%允许从任何远程主机登录到这个 MySQL 但不推荐)需要存在于运行在123.238.18.47.

有关如何实现此目的的 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.
于 2013-03-13T12:51:08.337 回答
15

您必须授予对 mysql 的访问权限。

创建新用户:

CREATE USER 'myuser'@'youripaddres' IDENTIFIED BY 'password';

对于下面的所有 ips 使用

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' WITH GRANT OPTION;

对于下面的特定 IP 使用

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'youripaddres' WITH GRANT OPTION;

需要psflush privileges;才能使更改生效。

于 2013-11-27T08:51:01.997 回答
2

我在这方面也不是很好,但我认为这个链接可以帮助你一点。这是我在使用 MySQL 时遇到问题时的参考。

你试一试。我希望它有效。 SourceForge.net

于 2012-06-20T04:41:34.680 回答