0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQLでクエリをキャンセル

Posted at

show processlist;からのKILL CONNECTION

実際にやってみる

準備

$ docker run -e MYSQL_ROOT_PASSWORD=pass -d mysql:5.7.24

クエリを流しておく

$ docker exec -it [container_id] /bin/bash
# mysql -h localhost -uroot -p
mysql> SELECT SLEEP(300);

別のコンソールから接続してキャンセル

$ docker exec -it [container_id] /bin/bash
# mysql -h localhost -uroot -p
mysql> show processlist;
+----+------+-----------+------+---------+------+------------+-------------------+
| Id | User | Host      | db   | Command | Time | State      | Info              |
+----+------+-----------+------+---------+------+------------+-------------------+
|  2 | root | localhost | NULL | Query   |    9 | User sleep | SELECT SLEEP(300) |
|  4 | root | localhost | NULL | Query   |    0 | starting   | show processlist  |
+----+------+-----------+------+---------+------+------------+-------------------+
2 rows in set (0.01 sec)

mysql>
mysql>
mysql> KILL CONNECTION 2;
Query OK, 0 rows affected (0.00 sec)

KILLの意味とか

13.7.6.4 KILL Syntax

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?