SET GLOBAL max_execution_time = 30000; -- milliseconds (30 seconds) Or per session/query:
How to Identify and Kill Long-Running Queries in MySQL mysql kill long running queries
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. First, check which queries are running longer than acceptable. SET GLOBAL max_execution_time = 30000; -- milliseconds (30