通過兩張表查看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。