-- 认真分析mysqbinlog的日志,其中前半部分使用的binlog_format=‘STATEMENT’,后半部分使用binlog_format=‘ROW’;
-- 所谓二进制文件,就是可以直接执行的文件。关于复制使用的就是该原理,将主库的二进制文件转化为自己的中继日志,然后执行实现同步
-- 同时可以执行SHOW BINLOG EVENTS IN 'mysql-bin.000085';
-- 针对使用ROW的如何解析,使用mysqlbinlog -v -v --base64-output=DECODE-ROWS mysql-bin.000085
-- 常用的几个参数
binlog_format = MIXED //binlog日志格式
log_bin=目录/mysql-bin.log //binlog日志名
expire_logs_days= 7 //binlog过期清理时间
max_binlog_size=100m //binlog每个日志文件大小
binlog-do-db=需要备份的数据库名,如果备份多个数据库,重复设置这个选项即可
binlog-ignore-db=不需要备份的数据库苦命,如果备份多个数据库,重复设置这个选项即可
http://www.cnblogs.com/jackluo/p/3336585.html
http://blog.itpub.net/22664653/viewspace-1158547/
C:\Users\Administrator>mysqlbinlog D:\mysql-bin.000085
/*!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
#161125 9:54:29 server id 1978 end_log_pos 120 CRC32 0x9bdc5124 Start: binlog v 4, server v 5.6.21-log created 161125 9:54:29
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
1Zk3WA+6BwAAdAAAAHgAAAABAAQANS42LjIxLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAASRR
3Js=
'/*!*/;
# at 120
#161125 9:54:59 server id 1978 end_log_pos 245 CRC32 0x8f4b9467 Query thread_id=1174 exec_time=0 error_code=0
SET TIMESTAMP=1480038899/*!*/; -- 设置时间点
SET @@session.pseudo_thread_id=1174/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -- 设置是否检查唯一,是否自动提交
SET @@session.sql_mode=0/*!*/;-- 设置SQL模式
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=33/*!*/;
SET @@session.time_zone='SYSTEM'/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 245 -- 开始位置 #at 1643330 :为事件的起点,是以1643330字节开始。
# at 277 -- 结束位置
#161125 9:54:59 server id 1978 end_log_pos 277 CRC32 0x6494e696 Intvar
SET INSERT_ID=3939/*!*/;-- 首先获取最大的插入ID
#161125 9:54:59 server id 1978 end_log_pos 539 CRC32 0x6a22608b Query thread_id=1174 exec_time=0 error_code=0
use `yz_app_schedule_db_1124`/*!*/;
SET TIMESTAMP=1480038899/*!*/;
insert into dbname.tbname 当状态为‘STATEMENT’的时候,显示执行的SQL语句
(
f1,
f2,
f3,
f4
)
values
(
22,
2000,
10,
now()
)
/*!*/;
# at 539
#161125 9:54:59 server id 1978 end_log_pos 570 CRC32 0xd39fd1cc Xid = 4753
COMMIT/*!*/;-- 提交
# at 570
#161125 9:58:57 server id 1978 end_log_pos 669 CRC32 0xab89275e Query thread_id=1174 exec_time=0 error_code=0
SET TIMESTAMP=1480039137/*!*/;
BEGIN
/*!*/;
# at 669
#161125 9:58:57 server id 1978 end_log_pos 752 CRC32 0xd7bbd705 Table_map: `dbname`.`system_push` mapped to number 557
# at 752
#161125 9:58:57 server id 1978 end_log_pos 829 CRC32 0x9fd432f6 Write_rows: table id 557 flags: STMT_END_F
BINLOG '
4Zo3WBO6BwAAUwAAAPACAAAAAC0CAAAAAAEAF3l6X2FwcF9zY2hlZHVsZV9kYl8xMTI0AAtzeXN0 -- 当状态为‘ROW’的时候,显示执行的SQL语句
ZW1fcHVzaAAHCAgIDxIRAwT8AwAAXgXXu9c=
4Zo3WB66BwAATQAAAD0DAAAAAC0CAAAAAAEAAgAH/4BkDwAAAAAAAPHUAQAAAAAA0AcAAAAAAAAC
ADEwmZrynrlYN5rhAAAAAPYy1J8=
'/*!*/;
# at 829
#161125 9:58:57 server id 1978 end_log_pos 860 CRC32 0x01e8b5e0 Xid = 4758
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
-- 单独的ROW文件的日志[INSERT操作]
BEGIN
/*!*/;
# at 326
#161125 10:42:43 server id 1978 end_log_pos 414 CRC32 0xde1aefd3 Table_map: `dbname`.tbname mapped to number 830 -- Table_map首先映射一个table_id
# at 414
#161125 10:42:43 server id 1978 end_log_pos 491 CRC32 0x3b7bab25 Write_rows: table id 830 flags: STMT_END_F -- 然后根据table_id进行写操作Write_rows
### INSERT INTO `dbname`.tbname
### SET
### @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2=1 /* INT meta=0 nullable=1 is_null=0 */
### @3='ddd' /* VARSTRING(44) meta=44 nullable=1 is_null=0 */
### @4=2 /* INT meta=0 nullable=1 is_null=0 */
### @5='味道' /* VARSTRING(44) meta=44 nullable=1 is_null=0 */
### @6=0 /* INT meta=0 nullable=1 is_null=0 */
### @7='正常' /* VARSTRING(44) meta=44 nullable=1 is_null=0 */