Kill Processes MySQL

First, execute below command to see all active processes.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SHOW PROCESSLIST;
SHOW PROCESSLIST;
SHOW PROCESSLIST;

Use below command to kill a specific process.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
KILL id;
KILL id;
KILL id;

Example

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
KILL 5;
KILL 5;
KILL 5;

Use below command to kill all processes.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SELECT CONCAT('KILL ',id,';')
FROM information_schema.processlist
WHERE user='root' INTO OUTFILE '/tmp/processlist.txt';
SELECT CONCAT('KILL ',id,';') FROM information_schema.processlist WHERE user='root' INTO OUTFILE '/tmp/processlist.txt';
SELECT CONCAT('KILL ',id,';') 
FROM information_schema.processlist 
WHERE user='root' INTO OUTFILE '/tmp/processlist.txt';

Use below command to kill all processes of a user.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
kill USER username;
kill USER username;
kill USER username;