MySQL 更改默认启动端口
查看 mysqld 服务运行状态
systemctl status mysqld
mysql 处于运行状态时,有两种方法可以查看端口
第一种 netstat 列出系统监听端口
netstat -lntp
第二种进入 mysql 查询 port 值
mysql -u root -p Enter password: mysql> show global variables like 'port'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.02 sec)
编辑 /etc/my.cnf
文件,在 [mysqld]
下添加 port=1234
vim /etc/my.cnf
#[mysqld]下面添加 自己设置的端口号
port=33060
保存退出,重启 mysql
systemctl restart mysqld