盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

mysql之binlog日志以及使用binlog日志恢复数据的示例代码分享

时间:2025/3/13作者:未知来源:盾怪网教程人气:

[摘要]+----+-----------+-----+-----+---------+2 rows in set (0.00 sec)mysql>查看mysq-bin00003日志,找出时间节点[r...
+----+-----------+-----+-----+---------+ 2 rows in set (0.00 sec) mysql>

查看mysq-bin00003日志,找出时间节点

[root@vm-002 ~]# cd /var/lib/mysql
[root@vm-002 mysql]# mysqlbinlog mysql-bin.000003 
.............
.............
BEGIN
/*!*/;
# at 173
#160925 21:57:19 server id 1 end_log_pos 201 Intvar
SET INSERT_ID=3/*!*/;
# at 201
#160925 21:57:19 server id 1 end_log_pos 444 Query thread_id=3 exec_time=0 error_code=0
use `ops`/*!*/;
SET TIMESTAMP=1474811839/*!*/;
insert into ops.member(`name`,`sex`,`age`,`classid`) values('yiyi','w',20,'cls1'),('xiaoer','m',22,'cls3'),
('zhangsan','w',21,'cls5'),('lisi','m',20,'cls4'),('wangwu','w',26,'cls6')                               
#执行的sql语句
/*!*/;
# at 444
#160925 
21:57:19
 server id 1 end_log_pos 471 Xid = 66    
#开始执行的时间
COMMIT
/*!*/;
# at 471
#160925 
21:58:41
 server id 1 end_log_pos 538 Query thread_id=3 exec_time=0 error_code=0    
#结束时间
SET TIMESTAMP=1474811921/*!*/;
BEGIN
/*!*/;
# at 538
#160925 
21:58:41
 server id 1 end_log_pos 646 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1474811921/*!*/;
update ops.member set name='李四' where id=4     
#执行的sql语句
/*!*/;
# at 646
#160925 
21:58:41
 server id 1 end_log_pos 673 Xid = 68    
#开始执行的时间
COMMIT/*!*/;
# at 673
#160925 
21:58:56
 server id 1 end_log_pos 740 Query thread_id=3 exec_time=0 error_code=0   
#结束时间
SET TIMESTAMP=1474811936/*!*/;
BEGIN
/*!*/;
# at 740
#160925 21:58:56 server id 1 end_log_pos 848 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1474811936/*!*/;
update ops.member set name='小二' where id=2     
 
#执行的sql语句
/*!*/;
# at 848
#160925 
21:58:56
 server id 1 end_log_pos 875 Xid = 69   
#开始执行的时间
COMMIT/*!*/;
# at 875
#160925 
22:01:08
 server id 1 end_log_pos 954 Query thread_id=3 exec_time=0 error_code=0    
#结束时间
SET TIMESTAMP=1474812068/*!*/;
drop database ops
/*!*/;
# at 954
#160925 22:09:46 server id 1 end_log_pos 997 Rotate to mysql-bin.000004 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

恢复到更改“name='李四'”之前的数据

[root@vm-002 ~]# /usr/bin/mysqlbinlog --start-datetime="2016-09-25 21:57:19" --stop-datetime="2016-09-25 21:58:41" --
database=ops /var/lib/mysql/mysql-bin.000003 

关键词:mysql之binlog日志以及运用binlog日志恢复数据的示例代码分享




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版