杀死 mysqld 进程
我有一个大约 800k 行的表。我运行了 update users set hash = SHA1(CONCAT({about 8 fields})) where 1;
现在我有一个挂起的 Sequel Pro 进程,我不确定 mysqld< /代码> 过程。
这是两个问题:
杀死这些程序可能会带来什么危害?我正在处理一个单独的数据库,因此系统上的其他数据库不会受到任何损害,对吧?
假设您必须更新这样的表。什么是更快/更可靠的更新方法而无需编写单独的脚本。
我刚刚检查了 phpMyAdmin,它看起来好像查询已完成。不过,我的 Sequel Pro 仍然 100% 使用我的两个核心......
I have a table with ~800k rows. I ran an update users set hash = SHA1(CONCAT({about eight fields})) where 1;
Now I have a hung Sequel Pro process and I'm not sure about the mysqld
process.
This is two questions:
What harm can possibly come from killing these programs? I'm working on a separate database, so no damage should come to other databases on the system, right?
Assume you had to update a table like this. What would be a quicker / more reliable method of updating without writing a separate script.
I just checked with phpMyAdmin and it appears as though the query is complete. I still have Sequel Pro using 100% of both my cores though...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 InnoDB,它由事务日志支持以用于恢复和回滚目的,那么您可以摆脱很多麻烦,尤其是在非生产环境中。
终止叛逆查询的最简单方法是使用 MySQL shell 作为 root 用户:
这将为您提供当前连接的列表以及每个连接的进程 ID。要终止任何给定的查询(例如编号 19),请使用:
通常这将撤消并回滚查询。在某些情况下,这还不够,您可能必须使用
kill -9
强制退出 MySQL 服务器进程。在大多数情况下,您应该能够立即重新启动服务器,并且数据库将处于上次完全提交的状态。If you're using InnoDB, which is backed by a transaction log for recovery and rollback purposes, then you can get away with a lot, especially in a non-production environment.
The easiest way to terminate a renegade query is to use the MySQL shell as the root user:
This will give you a list of the current connections and a process ID for each one. To terminate any given query, such as number 19, use:
Usually this will undo and roll back the query. In some cases this is not sufficient and you may have to force-quit the MySQL server process with
kill -9
. Under most circumstances you should be able to restart the server right away, and the DB will be in the last fully committed state.要获取线程 ID(它将在旁边显示查询):
要安全地终止查询线程:
除非您使用 innodb,否则您最终会得到部分更新的表,但应该没问题。 详细信息:
至于你的第二个问题,如果不允许编写单独的脚本(例如限制更新),则没有更好的方法来更新表。
To get the thread IDs (it'll show the query alongside):
To safely kill the query thread:
You'll end up with a partially updated table unless you use innodb, but you should be fine. Details:
As for your second question, there is no better way to update a table if one is not allowed to write a separate script (to, say, throttle the updates).