License: Attribution-NonCommercial-ShareAlike 4.0 International
本文出自 Suzf Blog。 如未注明,均为 SUZF.NET 原创。
有些时候由于MySQL 表和查询设计的不够好,常常以为一个SQL是这个数据库卡住亦或是查询变得灰常的慢。
那么我们该如何查到查询列表并杀死它们呢?
Here I go with solution.
- Login to DB.
- run command
show full processlist;
- Here you will get the process id with status and Query it self which causing the problem of hanging database.
- Now select the process id and run command
KILL <pid>;
- Now that point you kill that process.
Sometime that is not enough to kill each process manually. So, for that we've to go with some sort of trick. here I go with that trick:
- Login to MySql
- run that query
Select concat('KILL ',id,';') from information_schema.processlist where user='user';
- This will print all the process with KILL command.
- Copy all the query result, manipulate them and remove pipe
|
sign and paste all again into the query console. HIT ENTER. BooM its done.
相关连接
[0] https://dev.mysql.com/doc/refman/5.7/en/kill.html
[1] https://stackoverflow.com/questions/44192418/how-to-find-mysql-process-list-and-to-kill-those-processes
[2] https://stackoverflow.com/questions/1903838/how-do-i-kill-all-the-processes-in-mysql-show-processlist