Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a running procedure in MySQL?

I called a procedure in MySQL, but it is in an endless loop now! How to stop a running procedure in MySQL? The following is my procedure code:

drop procedure if exists my_proc; 
DELIMITER $$
CREATE PROCEDURE my_proc
()
BEGIN
DECLARE VAR INT;
SET VAR=0;
WHILE VAR<10000
DO
INSERT INTO my_table () VALUES ();
END WHILE;
END; $$
DELIMITER;

CALL my_proc();
like image 588
licaomeng Avatar asked Nov 23 '15 11:11

licaomeng


People also ask

How to stop a MySQL Query from running?

To stop the query the command call can be used with the given id that is in process list. The syntax for that is as follows − call mysql.rds_kill(valueOfGivenIdInProcesslist); Now, the above syntax is applied to the query and valueOfGivenIdInProcesslist is put as 8. This is shown below − mysql> CALL mysql.rds_kill(8);

How to stop a running MySQL Query with process ID?

In order to stop a running MySQL query, we can use the KILL command with process id. The syntax is as follows − Or you can stop a running MySQL query with the help of below syntax − Let us first get the processId with the help of show command. The query is as follows −

How to remove stored procedures in MySQL Workbench?

Second, click Review SQL to review the SQL statement that MySQL Workbench will apply to the database, or click the Drop Now if you want to immediately remove the stored procedure. Third, review the SQL code and click the Execute button to drop the stored procedure. Use DROP PROCEDURE statement to remove a stored procedure.

How to use the MySQL drop PROCEDURE statement?

Introduction to the MySQL DROP PROCEDURE statement. The DROP PROCEDURE deletes a stored procedure from the database. The following shows the syntax of the DROP PROCEDURE statement: DROP PROCEDURE [ IF EXISTS] stored_procedure_name; Code language: SQL (Structured Query Language) (sql) In this syntax: First, specify the name of of the stored ...


1 Answers

Connect to the server (or use phpmyadmin or something similar) and do:

SHOW PROCESSLIST;

Find the process causing trouble, note its ID and do:

KILL ID_OF_YOUR_PROCESS;
like image 181
maxhb Avatar answered Oct 13 '22 01:10

maxhb