设置允许指定端口通过防火墙centos7
1.systemctl start firewalld.service(开启防火墙)
2.systemctl stop firewalld.service(开启防火墙)
3.service firewalld restart(从启防火墙)
4.firewall-cmd --zone=public --add-port=4400-4600/udp --permanen(指定端口范围为4400-4600通过防火墙)
Warning: ALREADY_ENABLED: 3306:tcp(说明3306端口通过成功)
5.firewall-cmd --zone=public --remove-port=80/tcp --permanent(关闭指定端口)
6.firewall-cmd --zone=public --list-ports(查看通过的端口)
7.查看防火墙状态 :firewall-cmd --state
8.修改mysql密码:SET PASSWORD = PASSWORD('123456');
9.flush privileges;
10.grant all privileges on *.* to 'root'@'%' identified by'test1234';(将所root用户的所有ip 以密码为test1234登录)
11.flush privileges
12,在10前要先执行这个:update user set host = '%' where user = 'root';
13.在8前要先 use mysql
14.如何更改了mysql端口后 从启服务没有反应时 执行该命令:/usr/sbin/setenforce 0 (
开启了selinux,mysql会无法启动,你会在日志中看到以下错误
[ERROR] Can't start server: Bind on TCP/IP port: Permission denied
[ERROR] Do you already have another mysqld server running on port: 3308
)