欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux下修改mysql端口号

程序员文章站 2022-03-15 13:56:55
...

1.登录mysql

mysql -u root -p

 2.查看当前端口号

show global variables like 'port';

 3.修改端口:编辑/etc/my.cnf文件

vi /etc/my.cnf

 4. 增加或修改端口参数,然后保存退出

 [mysqld]

port=3308
log-bin=mysql-bin
server-id=2
max_allowed_packet=10M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

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

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
5.重启mysql

service mysqld restart