本文主要是介绍MySQL -- KILL + 客户端,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
KILL
KILL QUERY THREAD_ID
终止这个线程中正在执行的语句KILL [ CONNECTION ] THREAD_ID
断开这个线程的连接,如果该线程有语句在执行,先停止正在执行的语句
锁等待
表初始化
CREATE TABLE `t` (`id` INT(11) NOT NULL,`c` INT(11) NOT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB;INSERT INTO t VALUES (1,1);
操作次序
session A | session B | session C |
---|---|---|
BEGIN; | ||
UPDATE t SET c=c+1 WHERE id=1; | ||
UPDATE t SET c=c+2 WHERE id=1;(Blocked) | ||
SHOW PROCESSLIST; | ||
KILL QUERY 24; | ||
ERROR 1317 (70100): Query execution was interrupted |
mysql> SHOW PROCESSLIST;
+----+-----------------+-----------+------+---------+--------+------------------------+-------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+-----------+------+---------+--------+------------------------+-------------------------------+
| 4 | event_scheduler | localhost | NULL | Daemon |
这篇关于MySQL -- KILL + 客户端的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!