如何列出 MySQL 中所有正在运行的查询?
mysqlmysqli database
要列出正在运行的查询,我们需要使用"show processlist"命令。
以下是查询。
mysql> SHOW processlist;
以下是上述查询的输出。
+----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ | 4 | event_scheduler | localhost | NULL | Daemon | 13785 | Waiting on empty queue | NULL | | 9 | root | localhost:63587 | business | Query | 0 | starting | show processlist | +----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ 2 rows in set (0.00 sec)
让我们借助 SHOW 命令水平显示结果。
mysql> SHOW FULL PROCESSLIST\G;
以下是上述查询的输出。
*************************** 1. row *************************** Id: 4 User: event_scheduler Host: localhost db: NULL Command: Daemon Time: 17385 State: Waiting on empty queue Info: NULL *************************** 2. row *************************** Id: 9 User: root Host: localhost:63587 db: business Command: Query Time: 0 State: starting Info: SHOW FULL PROCESSLIST 2 rows in set (0.00 sec)