查看MySQL的线程

通过两张表查看MySQL的线程:information_schema.processlist 和 performance_schema.threads

processlist是information_schema数据库中的一张临时表:

通过表结构,大概能猜出:表中每一条记录对应一个客户端连接,也对应一个线程,即MySQL数据库为每一个连接开一个线程。

kill pid; 命令杀死线程,但是客户端的连接还在。

而threads是一张普通表:

show full processlist 可以查看用户连接的线程。

如果想查看其它用户的线程,需要赋权限。如给root用户赋权限:grant process on *.* to root;

如果想查看MySQL的所有线程: select t.thread_id, t.name, t.type, t.processlist_id from performance_schema.threads t ;

processlist_id是information_schema.processlist表的id。

原文地址:https://www.cnblogs.com/allenwas3/p/8541586.html