How to close all active connections?

1

I have 8 connections open in the database and would like to close all of them, is it possible?

What is the MySQL command that does this?

    
asked by anonymous 04.09.2015 / 22:04

1 answer

6

It does not exist directly but you can do this. Run this in MySQL:

select concat('KILL ',id,';') from information_schema.processlist where user='root' into outfile '/tmp/a.txt';

after

source /tmp/a.txt;

Font .

KILL Documentation .

You can also do this:

SELECT GROUP_CONCAT(CONCAT('KILL QUERY ',id,';') SEPARATOR ' ') KillQuery
FROM information_schema.processlist WHERE user<>'system user'\G

Font .

To run from the command line:

mysql -NBe "SELECT CONCAT('KILL ', id, ';') FROM information_schema.processlist WHERE user = 'some_username';" | mysql -vv

Font .

    
04.09.2015 / 22:14