加入收藏 | 设为首页 | 会员中心 | 我要投稿 财气旺网 - 财气网 (https://www.caiqiwang.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

Mysql误删除数据库怎么恢复

发布时间:2022-01-17 19:12:05 所属栏目:MySql教程 来源:互联网
导读:这篇文章主要讲解了Mysql误删除数据库怎么恢复,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习Mysql误删除数据库怎么恢复吧! ----误删除数据库恢复------------- 备份时间点: -- CHANGE MASTER TO MASTER_
          这篇文章主要讲解了“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误删除数据库怎么恢复这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。

(编辑:财气旺网 - 财气网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!