1.edit my.cnf
vim /etc/my.cnf
bind-address = 0.0.0.0 (modify 127.0.0.1 to 0.0.0.0)
/etc/init.d/mysqld restart
3.setting iptables
開放特定網域或IP
iptables -A INPUT -s 192.168.0.0/24 -m tcp -p tcp --dport 3306 -j ACCEPT
其他IP封鎖
iptables -A INPUT -p tcp --dport 3306 -j DROP
/etc/init.d/iptables save
/etc/init.d/iptables restart
2.connect mysql
GRANT ALL PRIVILEGES ON *.* TO username@'192.168.0.%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES; (使權限表生效)
沒有留言:
張貼留言