MySQL 更改端口
修改/etc/my.cnf
添加 port=3308
修改后如下
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port=3308
user=mysql
Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default-character-set=utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
然后重启 MySQL
如果你开启了 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
那么,你需要关掉 selinux,不想重启服务器,而关掉 selinux,使用以下命令
/usr/sbin/setenforce 0
修改 Linux 下 MySQL 端口时候报错:
Can't start server: Bind on TCP/IP port: Permission denied
需要修改: vi /etc/selinux/config
SELINUX=disabled
然后重启服务器即可