1、错误信息:2003 - Can't connect to MySQL server on '172.16.16.2' (61 "Connection refused")
2、查看该用户是否有远程登录的权限
root@172.16.16.2> select host,user from user;
  
3、查看mysql server是不是监听了3306端口
[root@localhost ~]# netstat -tulpen
  
4、这里如果没有监听3306端口或者只监听了localhost(0.0.0.0表示监听所有),则在my.cnf添加下面这一行
bind-address = 0.0.0.0
或者:bind-address =172.16.16.2
5、如果服务器是centos7,将mysql加入防火墙
[root@localhost ~]# sudo firewall-cmd --zone=public --permanent --add-service=mysql
6、返回success。然后继续执行
[root@localhost ~]# sudo systemctl restart firewalld
  
7、成功!
                    
                

                
            
        
浙公网安备 33010602011771号