Kill MySQL sessions
select Host, concat('KILL ',id,';') from information_schema.processlist where user='ksk_admin' and command ='Sleep' and Host LIKE 'ksksvr01%' ;
More example:-
mysql> select concat('KILL ',id,';') from information_schema.processlist where user='ksk_admin';
+------------------------+
| concat('KILL ',id,';') |
+------------------------+
| KILL 3001; |
| KILL 2133; |
+------------------------+
2 rows in set (0.00 sec)
mysql> select concat('KILL ',id,';') from information_schema.processlist where user='ksk_admin' into outfile '/tmp/ksk.txt';
Query OK, 2 rows affected (0.00 sec)
mysql> source /tmp/ksk.txt;
Query OK, 0 rows affected (0.00 sec)
select Host, concat('KILL ',id,';') from information_schema.processlist where user='ksk_admin' and command ='Sleep' and Host LIKE 'ksksvr01%' ;
More example:-
mysql> select concat('KILL ',id,';') from information_schema.processlist where user='ksk_admin';
+------------------------+
| concat('KILL ',id,';') |
+------------------------+
| KILL 3001; |
| KILL 2133; |
+------------------------+
2 rows in set (0.00 sec)
mysql> select concat('KILL ',id,';') from information_schema.processlist where user='ksk_admin' into outfile '/tmp/ksk.txt';
Query OK, 2 rows affected (0.00 sec)
mysql> source /tmp/ksk.txt;
Query OK, 0 rows affected (0.00 sec)
No comments:
Post a Comment