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)
本文介绍了一种使用MySQL的方法来批量生成并执行终止指定用户进程的命令。通过构造SQL语句并将结果导出到文件中,再从文件加载并执行这些命令,实现了对特定用户(如root)的所有活动进程的有效停止。
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)
710

被折叠的 条评论
为什么被折叠?