mysqlbinlog基于位置点恢复
基于位置点恢复
/data/mysq/mysqlbin.000026
#mysqlbinlog文件,恢复如下内容:
# at 406
#181113 17:15:44 server id 161 end_log_pos 523 CRC32 0x56f17177 Query thread_id=324 exec_time=0
SET TIMESTAMP=1542100544/*!*/;
insert into test values (1),(2),(4),(5) #想获取的内容
/*!*/;
# at 523
[root@a mysql]# mysqlbinlog mysqlbin.000026 --start-position=406 --stop-position=523 -r /opt/pos.sql #命令
[root@a mysql]# ll /opt/pos.sql
-rw-rw----. 1 root root 1450 Nov 13 17:28 /opt/pos.sql
[root@a ~]# cat /opt/pos.sql
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#181113 17:14:24 server id 161 end_log_pos 120 CRC32 0xcb43521c Start: binlog v 4, server v 5.6.27-log created 181113 17:14:24
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
8JXqWw+hAAAAdAAAAHgAAAABAAQANS42LjI3LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAARxS
Q8s=
'/*!*/;
# at 406
#181113 17:15:44 server id 161 end_log_pos 523 CRC32 0x56f17177 Query thread_id=324 exec_time=0 error_code=0
use `oldboy`/*!*/;
SET TIMESTAMP=1542100544/*!*/;
SET @@session.pseudo_thread_id=324/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1075838976/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
insert into test values (1),(2),(4),(5)
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
作者:Cherry_梅 出处:http://www.cnblogs.com/itqingtian/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。