杀死 mysqld 进程

发布于 2024-09-05 00:09:32 字数 435 浏览 3 评论 0原文

我有一个大约 800k 行的表。我运行了 update users set hash = SHA1(CONCAT({about 8 fields})) where 1;

现在我有一个挂起的 Sequel Pro 进程,我不确定 mysqld< /代码> 过程。

这是两个问题:

  1. 杀死这些程序可能会带来什么危害?我正在处理一个单独的数据库,因此系统上的其他数据库不会受到任何损害,对吧?

  2. 假设您必须更新这样的表。什么是更快/更可靠的更新方法而无需编写单独的脚本

我刚刚检查了 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:

  1. 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?

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

記柔刀 2024-09-12 00:09:32

如果您使用 InnoDB,它由事务日志支持以用于恢复和回滚目的,那么您可以摆脱很多麻烦,尤其是在非生产环境中。

终止叛逆查询的最简单方法是使用 MySQL shell 作为 root 用户:

SHOW PROCESSLIST;

这将为您提供当前连接的列表以及每个连接的进程 ID。要终止任何给定的查询(例如编号 19),请使用:

KILL 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:

SHOW PROCESSLIST;

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:

KILL 19;

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.

你怎么这么可爱啊 2024-09-12 00:09:32

要获取线程 ID(它将在旁边显示查询):

mysqladmin proc

要安全地终止查询线程:

mysqladmin kill [id]

除非您使用 innodb,否则您最终会得到部分更新的表,但应该没问题。 详细信息

在更新或删除操作期间,
每次之后都会检查终止标志
块读取并在每次更新或之后
已删除的行。如果设置了终止标志,
该语句被中止。请注意,如果
您没有使用交易,
更改不会回滚。

至于你的第二个问题,如果不允许编写单独的脚本(例如限制更新),则没有更好的方法来更新表。

To get the thread IDs (it'll show the query alongside):

mysqladmin proc

To safely kill the query thread:

mysqladmin kill [id]

You'll end up with a partially updated table unless you use innodb, but you should be fine. Details:

During UPDATE or DELETE operations,
the kill flag is checked after each
block read and after each updated or
deleted row. If the kill flag is set,
the statement is aborted. Note that if
you are not using transactions, the
changes are not rolled back.

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文