在 MySQL 中提交后有什么方法可以回滚吗?

2022-01-17 00:00:00 sql-update mysql rollback autocommit

我犯了一个大错误,我在 MySQL 中更新了一个没有 'where' 子句的表:'(

I did a big mistake that I updated a table without 'where' clause in MySQL :'(

它是自动提交的.

有什么办法可以回滚吗?

Is there any way to rollback from it?

推荐答案

不,没有查询可以撤消"已提交的数据修改查询.

No, there's no query that will "undo" a committed data-modifying query.

如果你有数据库的备份,你可以恢复备份并使用 DBA 工具(在 MySQL 的情况下,它是 mysqlbinlog) 以重播"自备份回数据库以来日志中的所有数据修改查询,但跳过问题查询.

If you have a backup of the database, you can restore the backup and use DBA tools (in MySQL's case, it's mysqlbinlog) to "replay" all data-modifying queries from the logs since the backup back to the database, but skip over the problem query.

如果您没有备份以及自该备份以来的所有日志,则您无法恢复数据.

If you don't have a backup and all logs since the that backup, there's nothing you can do to recover the data.

相关文章