简体   繁体   English

MySQL undo truncate table

[英]MySQL undo truncate table

One of my MySQL tables has been truncated by accident and I'd like to undo it so the data is returned. 我的一个MySQL表被意外截断了,我想撤消它以便返回数据。 Is there a log anywhere I can view the data truncated or possibly get back the data? 是否有任何日志我可以查看截断的数据或可能获取数据?

I've read about MySQL binary log, where are they stored? 我读过有关MySQL二进制日志的信息,它们存储在哪里? The last backup I have is from 3rd of may but I'd like to get back the data that has been truncated if possible. 我的最后一次备份是从5月3日开始,但是如果可能的话,我想取回已被截断的数据。

How do I solve: binary logs? 我该如何解决:二进制日志?

mysql_query("SHOW BINARY LOGS");

How do I view binary logs? 如何查看二进制日志?

You can use the mysqlbinlog utility to view the content of the binary log if binary logging is enabled for your MySQL Server instance. 如果为MySQL Server实例启用了二进制日志记录,则可以使用mysqlbinlog实用程序查看二进制日志的内容。 It will dump the binary log as a SQL script. 它会将二进制日志转储为SQL脚本。

You may still not be able to recover your data, as binary logs are sometimes a little tricky and contain just a few days of history. 您可能仍然无法恢复数据,因为二进制日志有时有点棘手并且只包含几天的历史记录。

I suggest that you read the documentation of the mysqlbinlog utility before attempting anything: https://dev.mysql.com/doc/refman/5.6/en/point-in-time-recovery.html 我建议您在尝试之前阅读mysqlbinlog实用程序的文档: https//dev.mysql.com/doc/refman/5.6/en/point-in-time-recovery.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM