这篇文章主要讲解了“误删除数据库怎么恢复”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“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
免责声明:本站发布的内容(图片、视频和文字)以原创、来自本网站内容采集于网络互联网转载等其它媒体和分享为主,内容观点不代表本网站立场,如侵犯了原作者的版权,请告知一经查实,将立刻删除涉嫌侵权内容,联系我们QQ:712375056,同时欢迎投稿传递力量。
Copyright © 2009-2022 56dr.com. All Rights Reserved. 特网科技 特网云 版权所有 特网科技 粤ICP备16109289号
域名注册服务机构:阿里云计算有限公司(万网) 域名服务机构:烟台帝思普网络科技有限公司(DNSPod) CDN服务:阿里云计算有限公司 百度云 中国互联网举报中心 增值电信业务经营许可证B2
建议您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流浏览器浏览本网站