Modify the mysql port number under linux

1. Login to mysql

mysql -u root -p

 2. View the current port number

show global variables like 'port';

 3. Modify the port: edit the /etc/my.cnf file

vi /etc/my.cnf

 4. Add or modify port parameters, then save and exit

 [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. Restart mysql

service mysqld restart

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326008786&siteId=291194637