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();
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);
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 −
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.
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 ...
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;
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