mysql批次kill session

甲骨文技術支援發表於2018-05-24


有時候需要批次kill掉session,可以用以下辦法,按照使用者查出來,然後session資訊,放到一個檔案裡,然後執行


  1. select concat('KILL ',id,';') from information_schema.processlist where user='xxx' into outfile '/var/lib/mysql-files/xxx.txt';
  2. select concat('KILL ',id,';') from information_schema.processlist where user='for_fin' into outfile '/var/lib/mysql-files/for_fin.txt';
  3. select concat('KILL ',id,';') from information_schema.processlist where user='for_201' into outfile '/var/lib/mysql-files/for_201.txt';
  4. select concat('KILL ',id,';') from information_schema.processlist where user='for_fin_ro' into outfile '/var/lib/mysql-files/for_fin_ro.txt';
 下面是執行這些session
  1.   source /var/lib/mysql-files/xxx.txt;
  2.   source /var/lib/mysql-files/for_fin.txt;
  3.   source /var/lib/mysql-files/for_201.txt;
  4.   source /var/lib/mysql-files/for_fin_ro.txt;


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20893244/viewspace-2155057/,如需轉載,請註明出處,否則將追究法律責任。

相關文章