如何停止執行 MySQL 查詢?

PHPz
發布: 2023-08-25 09:01:03
轉載
1448 人瀏覽過

如何停止运行 MySQL 查询?

在停止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中文網其他相關文章!

來源:tutorialspoint.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!