KILL 123;
KILL 123; -- Be cautious, as this terminates the entire connection mysql kill long running queries
Adjust the $THRESHOLD variable to your needs. Always test scripts in a controlled environment before running them on production systems. KILL 123; KILL 123; -- Be cautious, as
To find long-running queries, you can use the following methods: -- Be cautious
Once you've identified a long-running query you'd like to terminate, you can kill it using the KILL command followed by the query's ID (the Id column from SHOW PROCESSLIST or the equivalent).
Or, to kill the whole connection:
SELECT @thread_id := id FROM information_schema.processlist WHERE command = 'Query' AND time > @time_limit;