本篇内容介绍了“mysql怎么批量kill session”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
有时候需要批量kill掉session,可以用以下办法,按照用户查出来,然后session信息,放到一个文件里,然后执行
select concat('KILL ',id,';') from information_schema.processlist where user='xxx' into outfile '/var/lib/mysql-files/xxx.txt';
select concat('KILL ',id,';') from information_schema.processlist where user='for_fin' into outfile '/var/lib/mysql-files/for_fin.txt';
select concat('KILL ',id,';') from information_schema.processlist where user='for_201' into outfile '/var/lib/mysql-files/for_201.txt';
select concat('KILL ',id,';') from information_schema.processlist where user='for_fin_ro' into outfile '/var/lib/mysql-files/for_fin_ro.txt';
下面是执行这些session
source /var/lib/mysql-files/xxx.txt;
source /var/lib/mysql-files/for_fin.txt;
source /var/lib/mysql-files/for_201.txt;
source /var/lib/mysql-files/for_fin_ro.txt;
“mysql怎么批量kill session”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!