DBA Hub

📋Steps in this guide1/1

How to kill all sessions of an user

How to kill all sessions of an user

mysql configurationintermediate
by MYSQL
14 views
1

How to kill all sessions of an user

How to kill all sessions of an user Generate kill statements for killing all sessions of user root

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
mysql>
show processlist;
+----+-----------------+-----------+--------+---------+-------+------------------------+------------------+
| Id | User            | Host      | db     | Command | Time   | State                  | Info |
+----+-----------------+-----------+--------+---------+-------+------------------------+------------------+
| 5 | event_scheduler  | localhost | NULL  | Daemon   | 36418 | Waiting on empty queue | NULL |
| 24 | root | localhost | NULL     | Query | 0        | init  | show processlist        |
| 26 | root | localhost | test     | Sleep | 376      |       | NULL                    |
| 27 | root | localhost | testdb.  | Sleep | 347      |       | NULL                    |
+----+-----------------+-----------+--------+---------+-------+------------------------+------------------+
4 rows in set (0.00 sec)
mysql>
SELECT GROUP_CONCAT(CONCAT('KILL ',id,';') SEPARATOR ' ') 'Run the kill statements ----->>> ' FROM information_schema.processlist WHERE user='root'\G
*************************** 1. row ***************************
Run the kill statements ----->>> : KILL 24; KILL 26; KILL 27;
1 row in set (0.00 sec)
mysql>
KILL 24; KILL 26; KILL 27;
ERROR 1317 (70100): Query execution was interrupted
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id: 28
Current database: *** NONE ***
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)

Comments (0)

Please to add comments

No comments yet. Be the first to comment!