“ SHOW processlist”命令可用于显示仅与您的MySQL帐户相关的正在运行的线程。如果我们具有进程特权,则几乎可以看到所有正在运行的线程。它显示哪些线程正在运行。
以下是查询。
mysql> SHOW processlist;
这是输出。
+----+-----------------+-----------------+------+---------+------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+------+---------+------+------------------------+------------------+ | 4 | event_scheduler | localhost | NULL | Daemon | 968 | Waiting on empty queue | NULL | | 9 | root | localhost:50255 | NULL | Query | 0 | starting | show processlist | +----+-----------------+-----------------+------+---------+------+------------------------+------------------+ 2 rows in set (0.00 sec)
如果我们更改数据库,则输出将有所不同,但是始终会有以下两个用户:“ event_scheduler”和“ root”。
让我们再次尝试查询。
mysql> SHOW processlist;
以下是输出。
+----+-----------------+-----------------+----------+---------+------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+----------+---------+------+------------------------+------------------+ | 4 | event_scheduler | localhost | NULL | Daemon | 1148 | Waiting on empty queue | NULL | | 9 | root | localhost:50255 | business | Query | 0 | starting | show processlist | +----+-----------------+-----------------+----------+---------+------+------------------------+------------------+ 2 rows in set (0.00 sec)