is not allowed to connect to this MySQL serverConnection closed by foreign host.

telnet一个mysql服务器:

# telnet 192.168.xx.xx 3306
Trying 192.168.xx.xx...
Connected to 192.168.xx.xx.
Escape character is '^]'.
BHost '100.xx.xx.xx' is not allowed to connect to this MySQL serverConnection closed by foreign host.

可以ping通这个服务器,但是不能telnet通3306端口。

检查发现selinux和防火墙没有开启,中间也没有防火墙控制。

原因:

        虽然没有直接连接mysql,但是当telnet 3306端口的时候,如果在mysql里面没有这个连接服务器的ip地址的访问权限的用户,则telnet就会报这个错误。

        如果想要telnet不报错,则需要在数据库里面创建这个网段的用户,使其具有这个网段的用户。

例如:

grant select on gw.gw to gw@'100.%' identified by 'gw';

然后再telnet,就可以了。

你可能感兴趣的:(mysql,linux)