EHost' ip'不允许连接到此MySQL serverConnection

时间:2016-03-07 00:36:35

标签: mysql ubuntu amazon-ec2

我有两个实例:A和B

我正在尝试将实例A连接到实例B的mysql数据库。

在这两个实例中,我已将3600添加到安全组

enter image description here

我已编辑实例B /etc/mysql/my.cnf 添加0.0.0.0 作为绑定地址并重新启动mysql

[mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address       = 127.0.0.1
bind-address           = 0.0.0.0 
#
# * Fine Tuning
#
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8

但是当我在实例A终端上尝试telnet [Instance B public ip] 3306时,我得到了

  

EHost' [实例公共IP]'不允许连接到这个MySQL   serverConnection被外国主机关闭。

我是否错过了一步或做错了什么?

2 个答案:

答案 0 :(得分:1)

您是否在Instance B Mysql上拥有所有addAll的用户? 当您尝试使用telnet连接到mysql时,这是正常的行为。 尝试从Instance A

这样的东西
mysql -h [Instance B IP] -u [user_name] -p

答案 1 :(得分:1)

您应该授予IP权限以避免出现此错误

mysql -u root -p
Enter password
: <enter password>

>GRANT ALL ON *.* to root@'xx.xx.xx.xx' IDENTIFIED BY 'root';

>FLUSH PRIVILEGES;