温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Mysql误删除数据库怎么恢复

发布时间:2021-09-10 20:55:19 来源:亿速云 阅读:138 作者:chen 栏目:MySQL数据库

这篇文章主要讲解了“Mysql误删除数据库怎么恢复”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Mysql误删除数据库怎么恢复”吧!


----误删除数据库恢复-------------


备份时间点:
-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000211', MASTER_LOG_POS=12737491;


全备恢复:
mysql -uroot -p -h227.0.0.1<monitor_2016-05-24.sql  

分析binlog日志:
mysqlbinlog  -vvv mysql-bin.000211 --database=monitor >/tmp/monitor_binlog211.sql
mysqlbinlog  -vvv mysql-bin.000212 --database=monitor >/tmp/monitor_binlog212.sql


找出drop table的操作
grep -i "drop table" /tmp/monitor_binlog212.sql

找出误update操作:
mysqlbinlog  --no-defaults  -vvv mysql-bin.000710  --database=ticket --start-datetime="2016-06-21 16:05:00" |grep -B 50 '### UPDATE `ticket`.`cinema`'  |more

vi /tmp/monitor_binlog212.sql
/DROP TABLE IF EXISTS "analysedubborequest" 


# at 10970522
#160525 11:42:23 server id 108  end_log_pos 10970597 CRC32 0x3ccef367   Query   thread_id=162474        exec_time=0     error_code=0
SET TIMESTAMP=1464147743/*!*/;
BEGIN
/*!*/;
# at 10970597
# at 10970664
# at 10970886
#160525 11:42:23 server id 108  end_log_pos 10970917 CRC32 0xd89947f3   Xid = 24254453
COMMIT/*!*/;
# at 10970917
#160525 11:42:26 server id 108  end_log_pos 10971065 CRC32 0x3c4914bf   Query   thread_id=168489        exec_time=0     error_code=0
use `monitor`/*!*/;
SET TIMESTAMP=1464147746/*!*/;
SET @@session.foreign_key_checks=0/*!*/;
DROP TABLE IF EXISTS "analysedubborequest" /* generated by server */
/*!*/;
# at 10971065

注:
DROP TABLE IF EXISTS "analysedubborequest" /* generated by server */ 
在# at 10970917(start-position)和end_log_pos 10971065 (stop-position)删除操作在这个位置


增量恢复:
mysqlbinlog --start-position='12737491' mysql-bin.000211 --database=monitor | mysql -uroot -p
mysqlbinlog --stop-position='10970522' mysql-bin.000212 --database=monitor | mysql -uroot -p

其它:
查看binlog events:
show binlog events in 'mysql-bin.000212'\G 

基于时间点查看,不准
mysqlbinlog  -vvv mysql-bin.000212 --startdatetime='时间' --stopdatetime='时间' --database=monitor  

感谢各位的阅读,以上就是“Mysql误删除数据库怎么恢复”的内容了,经过本文的学习后,相信大家对Mysql误删除数据库怎么恢复这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI