MySQL 及 MariaDB 要检视已开启的连线数目, 可以用 MySQL 的 “show status” 指令查询。
“show status” 会显示 MySQL 执行时的一系统状态, 其中也包括了已开启连线数目。
首先登入 MySQL / MariaDB:
$ mysql -u root -p
Enter password:
Enter password:
登入 MySQL / MariaDB 后, 输入以下指令:
|
1 2 3 4 5 6 7 |
show status like '%connected'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_connected | 1 | +-------------------+-------+ 1 row in set (0.00 sec) |
从上面可以看到, 已开启的连线数是 1.
另一个方法是查看 MySQL processlist:
|
1 2 3 4 5 6 7 |
show processlist; +--------+--------+-----------+------+---------+------+-------+------------------+----------+ | Id | User | Host | db | Command | Time | State | Info | Progress | +--------+--------+-----------+------+---------+------+-------+------------------+----------+ | 181357 | phpini | localhost | NULL | Query | 0 | NULL | show processlist | 0.000 | +--------+--------+-----------+------+---------+------+-------+------------------+----------+ 1 row in set (0.00 sec) |
上面回传一笔资料 (1 row in set), 即已开启的连线数是 1.