Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel a mysql query

Is it possible to cancel a mysql query?

I have the problem that I submit a query which is very time-consuming because of a mistake. And now I can't make a new query because the server is working and working...

Or is there a way to stop all queries in a database or in a table.

For your information I am using phpMyAdmin (MySql).

like image 580
Wikunia Avatar asked Sep 19 '13 11:09

Wikunia


People also ask

How do you kill a query?

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.

How do you kill a process in MySQL?

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.


2 Answers

In phpMyAdmin, go to home page > Status; you'll see a list of your MySQL processes and you have a Kill link for each of them.

like image 102
Marc Delisle Avatar answered Oct 20 '22 18:10

Marc Delisle


Probably your phpMyAdmin will be stuck showing the "Searching" message. What you can do is to open another tab / open a MySQL session with the console and do the following:

Look for all the processes running:

SHOW PROCESSLIST;

And then kill that specific thread with the KILL command:

KILL <thread_id>;

Resources:

  • SHOW PROCESSLIST page in MySQL
  • KILL page in MySQL
like image 31
fedorqui 'SO stop harming' Avatar answered Oct 20 '22 16:10

fedorqui 'SO stop harming'