一、修改默认端口
# 编辑my.cnf文件
[root@centosServer ~]# vi /etc/my.cnf
# 修改默认端口3306
[mysqld]
port=3309
二、配置SELinux的semanage
# 【第一种方式】安装semanage
[root@centosServer ~]# yum -y provides semanage
[root@centosServer ~]# yum -y install policycoreutils-python.x86_64
[root@centosServer ~]# semanage port -a -t mysqld_port_t -p tcp 3309
# 或者
# 【第二种方式】临时关闭SELinux,或者永久关闭
[root@centosServer ~]# setenforce 0
三、重启服务
# 重启服务
[root@centosServer ~]# systemctl restart mysqld
# 查看端口
[root@centosServer ~]# netstat -nlpt
四、参考文章
mysql官网:https://dev.mysql.com/doc/refman/5.7/en/selinux-context-tcp-port.html
修改不生效方法:https://www.cnblogs.com/CUCKOO0615/p/13605416.html
关闭SELinux:https://www.cnblogs.com/gs008/p/12452523.html