SHOWprocesslist;这是输出。+----+-----------------+-----------------+------+---------+------+---------">

"show processlist"命令在 MySQL 中起什么作用?

mysqlmysqli database

"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)

相关文章