端口检测:
netstat -ntpl |grep 3306
如果只绑定了本机 参看1.3 否则参考2
- 打开mysql配置文件 vi /etc/my.cnf
不同的版本位置可能不同 如果有bind-address = 127.0.0.1 注释或者删掉 进入mysql 执行:
grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx'; //任何位置可以连接 flush privileges; //立即生效
开启防火墙3306端口
vi /etc/sysconfig/iptables //添加如下内容 -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT /etc/init.d/iptables restart(重启防火墙使配置生效) // 或者直接关闭防火墙;