1、网络不通。可以ping数据库主机,看是否能ping通。

2、mysql授权表里没有远程机器的权限,及需要在授权表mysql.user添加


grant all privileges on *.* to 'root'@'远程登陆IP' identified by '远程登陆密码'
flush privileges;
grant all privileges on *.* to 'root'@'远程登陆IP' identified by '远程登陆密码'
flush privileges;

3、防火墙禁止3306端口,以iptable为例

vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306-j ACCEPT  
service iptables restart 

iptables设置

  1. 重启后生效
    开启: chkconfig iptables on
    关闭: chkconfig iptables off

  2. 即时生效,重启后失效
    开启: service iptables start
    关闭: service iptables stop

更多推荐

MySQL数据库连接不上服务器 (10060错误)