Kill Mysql — Query

SELECT CONCAT('KILL ', id, ';') AS kill_command FROM information_schema.processlist WHERE user = 'app_user' AND command != 'Sleep'; Copy the output and execute it.

KILL 12345; Or with the optional CONNECTION keyword (same effect): kill mysql query

SHOW PROCESSLIST; Or for full, non-truncated queries: SELECT CONCAT('KILL ', id, ';') AS kill_command FROM

However, "killing" a MySQL query is not without risk. This piece covers how to do it, when it’s safe, and the potential consequences. Before you can kill a query, you need its Process ID (Thread ID) . Connect to MySQL via the command line or your admin interface and run: Before you can kill a query, you need

SELECT CONCAT('KILL ', id, ';') FROM information_schema.processlist WHERE time > 300; Sometimes you run KILL but the query remains in the process list with a state like Killed or Checking table . This means MySQL has acknowledged the kill command but is waiting for an internal resource (e.g., disk I/O, row lock) to release.

Shares