如何批量杀死MySQL进程

这期内容当中小编将会给大家带来有关如何批量杀死MySQL进程,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

杀掉当前所有的MySQL连接
方法1:
$ mysql -u root -p
Enter password: ******

mysql> select concat('KILL ',id,';') from information_schema.processlist where user='root';
+------------------------+
| concat('KILL ',id,';') |
+------------------------+
| KILL 9;                |
| KILL 8;                |
+------------------------+
2 rows in set (0.02 sec)


mysql>select concat('KILL ',id,';') from information_schema.processlist where user='root' into outfile '/tmp/kill.txt';
Query OK, 2 rows affected (0.00 sec)


mysql>source /tmp/kill.txt;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)


方法2:
shell脚本法:
$for id in `mysqladmin processlist| awk '{print $2}'`do mysqladmin -uroot -p123456 kill $id done

上述就是小编为大家分享的如何批量杀死MySQL进程了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注行业资讯频道。