Mysql show processlist
发布时间:2022-03-23 23:46:46

show full PROCESSLIST命令详解

show full processlistT显示哪些线程正在运行

show processlist;

只列出前100条,如果想全列出请使用show full processlist;

mysql> show processlist;
+-----+-----------------+------------------+--------------+---------+-------+------------------------+------------------+
| Id  | User            | Host             | db           | Command | Time  | State                  | Info             |
+-----+-----------------+------------------+--------------+---------+-------+------------------------+------------------+
|   5 | event_scheduler | localhost        | NULL         | Daemon  | 28556 | Waiting on empty queue | NULL             |
|  14 | root            | 172.19.0.1:61638 | redseanetxxx | Sleep   |   186 |                        | NULL             |
|  15 | root            | 172.19.0.1:61640 | redseanetxxx | Sleep   |   186 |                        | NULL             |
| 509 | root            | localhost        | NULL         | Query   |     0 | init                   | show processlist |
+-----+-----------------+------------------+--------------+---------+-------+------------------------+------------------+
4 rows in set (0.00 sec)

mysql> show full processlist;
+-----+-----------------+------------------+--------------+---------+-------+------------------------+-----------------------+
| Id  | User            | Host             | db           | Command | Time  | State                  | Info                  |
+-----+-----------------+------------------+--------------+---------+-------+------------------------+-----------------------+
|   5 | event_scheduler | localhost        | NULL         | Daemon  | 28562 | Waiting on empty queue | NULL                  |
|  14 | root            | 172.19.0.1:61638 | redseanetxxx | Sleep   |   192 |                        | NULL                  |
|  15 | root            | 172.19.0.1:61640 | redseanetxxx | Sleep   |   192 |                        | NULL                  |
| 509 | root            | localhost        | NULL         | Query   |     0 | init                   | show full processlist |
+-----+-----------------+------------------+--------------+---------+-------+------------------------+-----------------------+
4 rows in set (0.00 sec)

mysql>

 

id       #ID标识,要kill一个语句的时候很有用
use      #当前连接用户
host     #显示这个连接从哪个ip的哪个端口上发出
db       #数据库名
command  #连接状态,一般是休眠(sleep),查询(query),连接(connect)
time     #连接持续时间,单位是秒
state    #显示当前sql语句的状态
info     #显示这个sql语句