Linux下修改Mysql默认的3306端口,

如下:

1、登录Mysql后,查看当前端口

mysql> show global variables like 'port';  
+---------------+-------+  
| Variable_name | Value |  
+---------------+-------+  
| port | 3306 |  
+---------------+-------+  
1 row in set (0.00 sec)  

2. 修改端口,
编辑 /etc/my.cnf文件。  
新增 port=3301 参数,如下:

[root@test etc]# vi /etc/my.cnf  
[mysqld]  
port=3301  
...
....

3. 重新启动mysql  

[root@test ~]# service mysql restart
Stopping mysqld: [ OK ]  
Starting mysqld: [ OK ]  

4.再次登录后检查端口已修改为’3301’.  

mysql> show global variables like 'port';  
+---------------+-------+  
| Variable_name | Value |  
+---------------+-------+  
| port | 3301 |  
+---------------+-------+  
1 row in set (0.00 sec) 

 

Logo

更多推荐