How to change the connection port of mysql: first log in to mysql; then use the command [show global variables like & # 39; port & # 39;;] to check the port number; then modify the port; finally restart mysql.
【Related learning recommendation: mysql tutorial(video)】
How to change the connection port of mysql:
1. Log in to mysql
mysql -u root -p //Enter the password
2. Use the command show global variables like 'port';
to view the port number
mysql> show global variables like 'port';
3. Modify the port
Edit /etc/my.cnf file, earlier version It may be the name of the my.conf file, add the port parameter, 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 ]
For more programming learning, please pay attention to the PHP training column!
The above is the detailed content of how mysql changes the connection port. For more information, please pay attention to other related articles on 1024programmer.com!