Home > Database > Mysql Tutorial > 批量杀死 MySQL 连接

批量杀死 MySQL 连接

WBOY
Release: 2016-06-07 15:08:14
Original
1030 people have browsed it

下面简述 2 种方法 ㈠ 巧用 information_schema.processlist mysql select concat('KILL ',id,';') from information_schema.processlist where user='root' into outfile '/tmp/killall.txt';mysql source /tmp/killall.txt; ㈡ 在 Bash 层用 AWK 实现 ①

     下面简述 2 种方法
     

     ㈠ 巧用 information_schema.processlist


mysql> select concat('KILL ',id,';') from information_schema.processlist where user='root' into outfile '/tmp/killall.txt';

mysql> source /tmp/killall.txt;
Copy after login


     ㈡ 在 Bash 层用 AWK 实现
     
     ① 杀掉所有


mysqladmin -uroot -p processlist|awk -F "|" '{print $2}'|xargs -n 1 mysqladmin -uroot -p kill
Copy after login


     ② 杀掉指定、比如:Rocky


mysqladmin -uroot -p processlist|awk -F "|" '{if($3 == "Rocky")print $2}'|xargs -n 1 mysqladmin -uroot -p kill 
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template