MySQL STATEMENT和ROW 日志格式的内容区别

STATEMENT格式的日志文件记录的是日志的逻辑SQL语句。

[root@rhel6 data]# mysqlbinlog mysql-bin.000001
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#140425 10:15:47 server id 1 end_log_pos 107 Start: binlog v 4, server v 5.5.29-log created 140425 10:15:47 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG ‘
U8VZUw8BAAAAZwAAAGsAAAABAAQANS41LjI5LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABTxVlTEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
‘/*!*/;
# at 107
#140425 10:18:36 server id 1 end_log_pos 256 Querythread_id=1exec_time=0error_code=0
use `imkh`/*!*/;
SET TIMESTAMP=1398392316/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;
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.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
create table class(
id int auto_increment,
name char(4),
age tinyint,
primary key(id))
/*!*/;
# at 256
#140425 10:19:43 server id 1 end_log_pos 324 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398392383/*!*/;
BEGIN
/*!*/;
# at 324
#140425 10:19:43 server id 1 end_log_pos 352 Intvar
SET INSERT_ID=1/*!*/;
# at 352
#140425 10:19:43 server id 1 end_log_pos 456 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398392383/*!*/;
insert into class values (null,‘imkh‘,20)
/*!*/;
# at 456
#140425 10:19:43 server id 1 end_log_pos 483 Xid = 19
COMMIT/*!*/;
# at 483
#140425 10:19:58 server id 1 end_log_pos 551 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398392398/*!*/;
BEGIN
/*!*/;
# at 551
#140425 10:19:58 server id 1 end_log_pos 579 Intvar
SET INSERT_ID=2/*!*/;
# at 579
#140425 10:19:58 server id 1 end_log_pos 683 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398392398/*!*/;
insert into class values (null,‘juno‘,22)
/*!*/;
# at 683
#140425 10:19:58 server id 1 end_log_pos 710 Xid = 20
COMMIT/*!*/;
# at 710
#140425 10:20:33 server id 1 end_log_pos 778 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398392433/*!*/;
BEGIN
/*!*/;
# at 778
#140425 10:20:33 server id 1 end_log_pos 876 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398392433/*!*/;
update class set age=24 where id =2
/*!*/;
# at 876
#140425 10:20:33 server id 1 end_log_pos 903 Xid = 21
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;


ROW格式的日志文件记录的不再是简单的SQL语句了,而是记录表的行更改情况。

[root@rhel6 data]# mysqlbinlog --base64-output=DECODE-ROWS -v mysql-bin.000001
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#140425 10:28:04 server id 1 end_log_pos 107 Start: binlog v 4, server v 5.5.29-log created 140425 10:28:04 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
# at 107
#140425 10:30:17 server id 1 end_log_pos 256 Querythread_id=1exec_time=0error_code=0
use `imkh`/*!*/;
SET TIMESTAMP=1398393017/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;
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.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
create table class(
id int auto_increment,
name char(4),
age tinyint,
primary key(id))
/*!*/;
# at 256
#140425 10:30:35 server id 1 end_log_pos 324 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398393035/*!*/;
BEGIN
/*!*/;
# at 324
# at 372
#140425 10:30:35 server id 1 end_log_pos 372 Table_map: `imkh`.`class` mapped to number 33
#140425 10:30:35 server id 1 end_log_pos 412 Write_rows: table id 33 flags: STMT_END_F
### INSERT INTO `imkh`.`class`
### SET
### @1=1
### @2=‘imkh‘
### @3=20
# at 412
#140425 10:30:35 server id 1 end_log_pos 439 Xid = 11
COMMIT/*!*/;
# at 439
#140425 10:30:42 server id 1 end_log_pos 507 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398393042/*!*/;
BEGIN
/*!*/;
# at 507
# at 555
#140425 10:30:42 server id 1 end_log_pos 555 Table_map: `imkh`.`class` mapped to number 33
#140425 10:30:42 server id 1 end_log_pos 595 Write_rows: table id 33 flags: STMT_END_F
### INSERT INTO `imkh`.`class`
### SET
### @1=2
### @2=‘juno‘
### @3=22
# at 595
#140425 10:30:42 server id 1 end_log_pos 622 Xid = 12
COMMIT/*!*/;
# at 622
#140425 10:31:08 server id 1 end_log_pos 690 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1398393068/*!*/;
BEGIN
/*!*/;
# at 690
# at 738
#140425 10:31:08 server id 1 end_log_pos 738 Table_map: `imkh`.`class` mapped to number 33
#140425 10:31:08 server id 1 end_log_pos 790 Update_rows: table id 33 flags: STMT_END_F
### UPDATE `imkh`.`class`
### WHERE
### @1=2
### @2=‘juno‘
### @3=22
### SET
### @1=2
### @2=‘juno‘
### @3=24
# at 790
#140425 10:31:08 server id 1 end_log_pos 817 Xid = 14
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;


MySQL STATEMENT和ROW 日志格式的内容区别,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。