How to find MySQL process list and to kill those processes?

Ashish Dadhich picture Ashish Dadhich · May 26, 2017 · Viewed 226.2k times · Source

The MySQL database hangs, due to some queries.

How can I find the processes and kill them?

Answer

Ashish Dadhich picture Ashish Dadhich · May 26, 2017

Here is the solution:

  1. Login to DB;
  2. Run a command show full processlist;to get the process id with status and query itself which causes the database hanging;
  3. Select the process id and run a command KILL <pid>; to kill that process.

Sometimes it is not enough to kill each process manually. So, for that we've to go with some trick:

  1. Login to MySQL;
  2. Run a query Select concat('KILL ',id,';') from information_schema.processlist where user='user'; to print all processes with KILL command;
  3. Copy the query result, paste and remove a pipe | sign, copy and paste all again into the query console. HIT ENTER. BooM it's done.