KILL QUERY 123; -- Replace 123 with the actual query ID
: Run SHOW FULL PROCESSLIST; in the MySQL command line.
Use when an application needs to remain connected but needs a specific heavy query stopped.
#!/bin/bash
Long-running queries can cripple your database performance, consume server resources, and lead to application timeouts. Here’s how to spot and terminate them in MySQL.
SHOW PROCESSLIST;
Or per session/query:
-- Usage CALL kill_long_running_queries(120); -- kills queries running > 2 minutes
Example:
: This column contains the actual SQL statement being executed. mysql kill long running queries
1 Comment. Add a comment. Kip. Kip Over a year ago. Note: That last query is required if using AWS RDS instance. 2017-03-23T19:49: Stack Overflow Identify and Kill Queries with MySQL Command-Line Tool
```sql SELECT * FROM information_schema.processlist;