如何停止运行 MySQL 查询?

PHPz
发布: 2023-08-25 09:01:03
转载
1446 人浏览过

如何停止运行 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 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学习者快速成长!