修改端口号
2023-02-28 小于 1 分钟
# 登录mysql
mysql -uroot -p;
1
# 查看当前端口号
mysql> show global variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)
1
2
3
4
5
6
7
2
3
4
5
6
7
# 修改端口号
编辑/etc/my.cnf文件
port=7701
skip-grant-tables
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
1
2
3
4
2
3
4
# 重启
systemctl stop mysqld
systemctl start mysql
1
2
3
2
3
# 验证
mysql> show global variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 7701 |
+---------------+-------+
1 row in set (0.00 sec)
1
2
3
4
5
6
7
2
3
4
5
6
7