可以通过threads_connected变量了解活动连接或总连接。该变量说明当前打开的连接数。
查询如下-
mysql> show status where `variable_name` = 'Threads_connected';
这是输出。
+-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_connected | 1 | +-------------------+-------+ 1 row in set (0.06 sec)
我们可以在show命令的帮助下进行检查。查询如下-
mysql> show processlist;
这是输出。
+----+-----------------+-----------------+----------+---------+--------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+----------+---------+--------+------------------------+------------------+ | 4 | event_scheduler | localhost | NULL | Daemon | 349012 | Waiting on empty queue | NULL | | 11 | root | localhost:54746 | business | Query | 1 | starting | show processlist | +----+-----------------+-----------------+----------+---------+--------+------------------------+------------------+ 2 rows in set (0.31 sec)