[iyunv@centos-server ~]$ mysql --host localhost --user root --password mysql
mysql> CREATE USER 'amonest'@'%' IDENTIFIED BY 'xxx';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'amonest'@'%' WITH GRANT OPTION;
关于MySQL帐号和权限的信息请参考《6.3.2. Adding User Accounts》和《13.7.1.3. GRANT Syntax》。
2. 配置防火墙。原来的防火墙策略如下:
[iyunv@centos-server ~]$ iptables -L -n --line-numbers
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 state NEW
6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
按照下面的方式开启MySQL的3306端口:
[iyunv@centos-server ~]$ iptables -I INPUT 6 -p tcp -m tcp --dport 3306 -m state --state NEW -j ACCEPT
[iyunv@centos-server ~]$ service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[iyunv@centos-server ~]$ service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]