The MySQL port defaults to 3306, but the MySQL port may be modified during the installation process.
1. Log in to mysql
[root@localhost ~]# mysql -uroot -pEnter password: Enter the database password;
2 , use the show global variables like ‘port’; command to view the port number,
mysql> show global variables like ‘port’; ————— ——- | Variable_name | Value | ————— ——- | port | 3306 | ##mysql>
3306 is the port number.
2. Modification of mysql port number
1. Edit the /etc/my.cnf file [root@localhost ~]# vi /etc/my.cnf
2 , add port=2032;
3, restart mysql [root@localhost ~]# /etc/init.d/mysqld restart
The above is the detailed content of How to check the MySQL port under Linux. For more information, please follow other related articles on the PHP Chinese website!