如何批量杀死当前的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

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

转载于:http://blog.itpub.net/15498/viewspace-2125232/

你可能感兴趣的:(如何批量杀死当前的MySQL进程)