Mysql
 SQL >> Datenbank >  >> RDS >> Mysql

Alle Prozesse in MySQL SHOW PROCESSLIST beenden?

Eine Massen-Beendigung spart Zeit. Mach es direkt in MySQL:

Führe diese Befehle aus:

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

Referenz

---------edit------------

Wenn du nichts in eine Datei schreiben willst, speichere es in einer Variable. Führe einfach in deiner Eingabeaufforderung aus:

> out1=$(mysql -B test -uroot -proot --disable-column-names -e "select concat('KILL ',id,';') from information_schema.processlist where user='root' and time > 200;")
> out2= $(mysql -B test -uroot -proot --disable-column-names -e "$out1")