mysql> SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root';
+------------------------+
| concat('KILL ',id,';') |
+------------------------+
| KILL 21107; |
+------------------------+
1 row in set (0.01 sec)
mysql> SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root' INTO OUTFILE '/tmp/killid.txt';
Query OK, 1 row affected (0.01 sec)
mysql> source /tmp/killid.txt;