Is there any way to rollback after commit in MySQL?

放肆的年华 提交于 2019-11-27 02:05:50

问题


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

It is auto-committed.

Is there any way to rollback from it?


回答1:


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

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.




回答2:


Look up transaction logs. I'll update with more info but the logs may only stay around for a limited time so time is of the essence!

See: http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html




回答3:


If you have enabled mysql binlog and also it is of ROW based format, then you can get the value for each row before & after the update. Using that you can restore the table's state.



来源:https://stackoverflow.com/questions/14016278/is-there-any-way-to-rollback-after-commit-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!