在停止MySQL的執行查詢之前,我們首先需要看到有多少個行程。
使用show指令運行。查詢如下圖−
mysql> show processlist;
After executing the above query, we will get the output with some id's. This is given as follows −
+----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ | 4 | event_scheduler | localhost | NULL | Daemon | 71034 | Waiting on empty queue | NULL | | 8 | Manish | localhost:53496 | business | Query | 0 | starting |show processlist| +----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ 2 rows in set (0.00 sec)
As seen from the the above output, the db currently in use is 'business'. and its id is 8. To stop the 查詢命令呼叫可以與給定的正在運行的進程列表中的ID一起使用。其語法為: is as follows −
call mysql.rds_kill(valueOfGivenIdInProcesslist);
Now, the above syntax is applied to the query and valueOfGivenIdInProcesslist is put as 8. This 下面顯示的是 −
mysql> CALL mysql.rds_kill(8);
執行上述查詢後,得到以下輸出 −
ERROR 2013 (HY000): Lost connection to MySQL server during query
#當上述查詢停止執行時,就會發生這種情況。使用`use`指令來檢查它是否有
stopped or not. The syntax for that is as follows −use yourDatabaseName;
The above syntax is applied to the mydatabase name ‘business’ in the system. The query is as follows −
mysql> use business;
執行上述查詢後,獲得以下輸出 −
No connection. Trying to reconnect... Connection id: 10 Current database: *** NONE *** Database changed mysql>
因此,很明顯查詢已經停止,因為訊息是“正在嘗試...” 在MySQL中,"reconnect…”"的意思是重新連接。同時也顯示當前資料庫為"none”。經過一段時間後, 時間與資料庫的連線恢復。
以上是如何停止執行 MySQL 查詢?的詳細內容。更多資訊請關注PHP中文網其他相關文章!