ITPub博客

首页 > 数据库 > MySQL > 批量kill mysql processlist进程

批量kill mysql processlist进程

原创 MySQL 作者:haoge0205 时间:2015-12-01 23:10:54 0 删除 编辑
如果大批量的操作能够通过一系列的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/

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28939273/viewspace-1851046/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-11-28

  • 博文量
    300
  • 访问量
    1893491