1.阿里雲后台安全實例,添加開啟mysql端口3306,入方向
2.登錄到mysql, 授權外部可鏈接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;
FLUSH PRIVILEGES;
3.修改my.cnf配置[mysqld中]。添加
bind-address = 0.0.0.0
4.重啟mysql,/etc/init.d/mysql restart
打開端口:
iptables -I INPUT -i eth0 -p tcp --dport 3306 -j ACCEPT #開放3690端口
service iptables save #保存iptable規則
啟動防火牆:
systemctl start firewalld # 啟動,
systemctl enable firewalld # 開機啟動
systemctl stop firewalld # 關閉
systemctl disable firewalld # 取消開機啟動
或者:
3、防火牆檢測
1)iptables --list查看;
2)開啟防火牆3306端口
vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT(允許3306端口通過防火牆)
/etc/init.d/iptables restart(重啟防火牆使配置生效)
3)或者直接關閉防火牆; 參考:http://blog.csdn.net/fjssharpsword/article/details/50973283
centos 7 以后是修改 firewall
systemctl start firewalld # 啟動,
systemctl enable firewalld # 開機啟動
systemctl stop firewalld # 關閉
systemctl disable firewalld # 取消開機啟動
5.還不行就重啟服務器。