批量kill mysql进程

如果大批量的操作能够通过一系列的select语句产生,那么理论上就能对这些结果批量处理。
但是mysql并没用提供eval这样的对结果集进行分析操作的功能。所以只能现将select结果保存到临时文件中,然后再执行临时文件中的指令。
具体过程如下:

mysql> SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root';
+------------------------+
| concat('KILL ',id,';')
+------------------------+
| KILL 3101;             
| KILL 2946;             
+------------------------+
2 rows IN SET (0.00 sec)

mysql> SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root' INTO OUTFILE '/tmp/a.txt';
Query OK, 2 rows affected (0.00 sec)

mysql> source /tmp/a.txt;
Query OK, 0 rows affected (0.00 sec)

 原文地址 http://www.mysqlperformanceblog.com/2009/05/21/mass-killing-of-mysql-connections/
原文地址:https://www.cnblogs.com/feihongwuhen/p/7170398.html