Home  >  Article  >  Database  >  How to change the connection port in mysql

How to change the connection port in mysql

coldplay.xixi
coldplay.xixiOriginal
2020-09-03 15:21:0816313browse

Mysql method to change the connection port: first log in to mysql; then use the command [show global variables like 'port';] to view the port number; then modify the port; and finally restart mysql.

How to change the connection port in mysql

【Related learning recommendations: mysql tutorial(Video)】

Mysql method to change the connection port:

1. Log in to mysql

mysql -u root -p
//输入密码

2. Use the command show global variables like 'port';Check the port number

mysql> show global variables like 'port';

3. Modify the port

Edit the /etc/my.cnf file. In earlier versions, it may be the my.conf file name, and add port parameters. , and set the port. Note that the port is not used, save and exit.

[root@test etc]# vi my.cnf
[mysqld]
port=3506
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
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
 
"my.cnf" 11L, 261C written
[root@test etc]#

4. Restart mysql

[root@test ~]# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]

If you want to learn more about programming, please pay attention to the php training column!

The above is the detailed content of How to change the connection port in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn