Linux CentOS Mysql修改默认端口

Linux下如何修改Mysql端口。支持Linux环境下大部分系统的修改,如Centos和Ubuntu等。

演示环境:
Linux CentOS 6.4 X64
Mysql

一、编辑my.conf
vi /etc/my.conf

二、在[mysqld]下添加port=9060

[mysqld]
port=9060
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
wait_timeout=2880000
interactive_timeout=2880000
max_allowed_packet=15M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 

三、重启mysql服务
#/etc/init.d/mysqld restart

Tips:
0、9060是你想要修改的端口;
1、修改后记得将端口添加进iptables;
2、更新了mysql端口,可能已网站会无法连接上,记得在网站配置文件加上端口;注意防火墙是否开启该端口
3、如果修改之后无法重启服务,请检查
a、使用的端口会不会给占用?
b、编辑/etc/my.conf 添加[client] port=9060

[mysqld]
port=9060
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
wait_timeout=2880000
interactive_timeout=2880000
max_allowed_packet=15M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[client]
port=9060


c、添加后再重启mysql服务

阅读更多

没有更多推荐了,返回首页