MySQL 查询正在锁定表,无法终止该进程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15932058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Query is locking tables, can't kill that process
提问by Mike
I have a query locking tables in MySQL (using InnoDB):
我在 MySQL 中有一个查询锁定表(使用 InnoDB):
UPDATE table SET status = 2 WHERE status = 3
This query caused a deadlock on the table and can't bypass it.
此查询导致表上出现死锁并且无法绕过它。
I tried to do:
我试图做:
show processlist
then kill the process id but i can't seems to kill it
然后杀死进程ID,但我似乎无法杀死它
I tried:
我试过:
kill 9588
9588 is the process id.
9588 是进程 ID。
Then I do show processlistI still see the same query on the list.
然后我show processlist仍然在列表中看到相同的查询。
How can I force killing this process and then why would this query cause a dead lock? how can I fix it?
我怎样才能强制终止这个进程,然后为什么这个查询会导致死锁?我该如何解决?
回答by Eric Leschinski
When you run a MySQL instance on RDS and want to kill a thread or a query for some reason, you'll find you cannot use KILLor mysqladmin killbecause you don't have a permission to do so.
当您在 RDS 上运行 MySQL 实例并出于某种原因想要杀死一个线程或查询时,您会发现您无法使用KILL或mysqladmin kill因为您没有权限这样做。
RDS provides the stored procedures named mysql.rds_killand mysql.rds_kill_querywhich will kill a thread and a query respectively. To kill a thread, first use SHOW PROCESSLISTto get the list of threads and find the id of the thread you want to kill. Assuming the thread id is 53512, then use
RDS 提供了名为mysql.rds_kill和的存储过程,mysql.rds_kill_query它们将分别杀死一个线程和一个查询。要杀死一个线程,首先使用SHOW PROCESSLIST获取线程列表并找到要杀死的线程的 id。假设线程id是53512,那么使用
CALL mysql.rds_kill(53512)
Source: http://snak.tumblr.com/post/13856391340/killing-a-thread-or-query-of-mysql-running-on-rds
来源:http: //snak.tumblr.com/post/13856391340/killing-a-thread-or-query-of-mysql-running-on-rds
回答by tadman
The KILLcommand requests the query terminate, and the state of the command should show up as Killed. There's no way to force-kill something and have it terminate immediately.
该KILL命令请求终止查询,并且该命令的状态应显示为Killed。没有办法强制杀死某些东西并让它立即终止。
As a last resort you can always shut-down and restart your mysqldserver process.
作为最后的手段,您可以随时关闭并重新启动mysqld服务器进程。
回答by Shivam Kubde
You need to run following command to kill the process.
您需要运行以下命令来终止进程。
> show processlist;
> kill query processId;
Query parameter specifies that we need to kill query command process.
查询参数指定我们需要杀死查询命令进程。
The syntax for kill process as follows
杀死进程的语法如下
KILL [CONNECTION | QUERY] processlist_id
杀死[连接| QUERY] processlist_id
Please referthis link for more information.
请参阅此链接以获取更多信息。
回答by Robert Heeren
you should try to kill the mysql/sql serviceon you computer first and than tray to kill the the program you are runnen white the query.
您应该先尝试杀死mysql/sql service计算机上的程序,然后再用托盘杀死正在运行的程序。
hope it will work for you
希望它对你有用

