下文为各位整理了一些关于shell指令结束mysql指定用户的所有进程的方法了,这些方法非常的实用希望对各位同学会带来帮助的哦。
例子,在linux中操作
$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)
|