Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7484875
  • 博文数量: 368
  • 博客积分: 9600
  • 博客等级: 上校
  • 技术积分: 18875
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-01 00:00
文章分类

全部博文(368)

文章存档

2017年(9)

2016年(19)

2015年(3)

2014年(6)

2013年(8)

2012年(78)

2011年(66)

2010年(135)

2009年(44)

分类: LINUX

2010-08-07 11:43:48

如果大批量的操作能够通过一系列的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/
阅读(6640) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~