一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

shell指令结束mysql指定用户的所有进程

时间:2015-08-31 编辑:简简单单 来源:一聚教程网

例子,在linux中操作

QQ图片20150812190828

$2横向第二栏用户栏

 代码如下 复制代码
for i in $(mysql -uroot -p123456 -se "show processlist" |
awk '{if($2=="admin")print $1}');do mysql -uroot -p123456 -e "kill $i";done

例子,在mysql中解决

 代码如下 复制代码

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)

热门栏目