1、登录mysql
[root@localhost ~]# mysql -uroot -p
Enter password: 输入数据库密码;
2、使用show global variables like ‘port’; 命令查看端口号,
mysql> show global variables like 'port';
±--------------±------+
| Variable_name | Value |
±--------------±------+
| port | 3306 |
±--------------±------+
1 row in set (0.00 sec)
mysql>
3306即为端口号。