I connect to mysql
from my Linux shell. Every now and then I run a SELECT
query that is too big. It prints and prints and I already know this is not what I meant. I would like to stop the query.
Hitting Ctrl+C
(a couple of times) kills mysql
completely and takes me back to shell, so I have to reconnect.
Is it possible to stop a query without killing mysql
itself?
KILL allows the optional CONNECTION or QUERY modifier: KILL CONNECTION is the same as KILL with no modifier: It terminates the connection associated with the given thread or query id. KILL QUERY terminates the statement that the connection thread_id is currently executing, but leaves the connection itself intact.
MySQL does not have a unique command for killing all processes. To kill all processes for a specific user, use CONCAT to create a file with the list of threads and statements. In our case, we entered root as the user. To specify another user, replace root with the desired username.
mysql>show processlist; mysql> kill "number from first col";
Just to add
KILL QUERY **Id**
where Id is connection id from show processlist
is more preferable if you are do not want to kill the connection usually when running from some application.
For more details you can read mysql doc here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With