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.
【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!