1.阿里雲後臺安全實例,添加開啓mysql端口3306,入方向mysql
2.登陸到mysql, 受權外部可連接sql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;centos
FLUSH PRIVILEGES;安全
3.修改my.cnf配置[mysqld中]。添加bash
bind-address = 0.0.0.0服務器
4.重啓mysql,/etc/init.d/mysql restart ssh
打開端口:tcp
iptables -I INPUT -i eth0 -p tcp --dport 3306 -j ACCEPT #開放3690端口阿里雲
spa
service iptables save #保存iptable規則
啓動防火牆:
systemctl start firewalld # 啓動,
systemctl enable firewalld # 開機啓動
systemctl stop firewalld # 關閉
systemctl disable firewalld # 取消開機啓動
或者:
三、防火牆檢測
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.還不行就重啓服務器。