mysql的二进制日志是怎样保存的
本篇内容介绍了“MySQL的二进制日志是怎样保存的”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
创新互联长期为近千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为湘阴企业提供专业的成都做网站、成都网站制作,湘阴网站改版等技术服务。拥有10年丰富建站经验和众多成功案例,为您定制开发。
说明
1、statement基于SQL语句,每个涉及修改的sql都会记录在binlog中。
缺点:日志量过大,如sleep()函数、last_insert_id()>、user-definedfuctions(udf)、主从复制等。
2、ROW基于行,只记录变化的记录,不记录sql的上下文环境。
缺点:如果遇到update..set..wheretrue,binlog的数据量会增加。
3、建议使用MIXED,语句采用statement。
函数采用ROW存储。
实例
# lee @ acer in /var/log/mysql [14:45:44] $ mysqlbinlog -vv mysql-bin.000076 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #170713 14:35:53 server id 1 end_log_pos 123 CRC32 0xbf52e415 Start: binlog v 4, server v 5.7.18-0ubuntu0.16.04.1-log created 170713 14:35:53 # Warning: this binlog is either in use or was not closed properly. BINLOG ' yRRnWQ8BAAAAdwAAAHsAAAABAAQANS43LjE4LTB1YnVudHUwLjE2LjA0LjEtbG9nAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA ARXkUr8= '/*!*/; # at 123 #170713 14:35:53 server id 1 end_log_pos 154 CRC32 0xafecf53d Previous-GTIDs # [empty] # at 154 #170713 14:43:03 server id 1 end_log_pos 219 CRC32 0x491b5a7e Anonymous_GTID last_committed=0 sequence_number=1 SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; # at 219 #170713 14:43:03 server id 1 end_log_pos 318 CRC32 0x4acf1cd1 Query thread_id=8 exec_time=0 error_code=0 use `test`/*!*/; SET TIMESTAMP=1499928183/*!*/; SET @@session.pseudo_thread_id=8/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=1436549152/*!*/; 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/*!*/; alter table t add c2 text /*!*/; # at 318 #170713 14:44:02 server id 1 end_log_pos 383 CRC32 0x8437eaf9 Anonymous_GTID last_committed=1 sequence_number=2 SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; # at 383 #170713 14:44:02 server id 1 end_log_pos 455 CRC32 0x57adaf15 Query thread_id=8 exec_time=0 error_code=0 SET TIMESTAMP=1499928242/*!*/; BEGIN /*!*/; # at 455 #170713 14:44:02 server id 1 end_log_pos 504 CRC32 0xdba65133 Table_map: `test`.`t` mapped to number 498 # at 504 #170713 14:44:02 server id 1 end_log_pos 556 CRC32 0x19769a28 Write_rows: table id 498 flags: STMT_END_F BINLOG ' shZnWRMBAAAAMQAAAPgBAAAAAPIBAAAAAAEABHRlc3QAAXQAAwMP/AMeAAIHM1Gm2w== shZnWR4BAAAANAAAACwCAAAAAPIBAAAAAAEAAgAD//gDAAAABGhhaGEFAGxsYWxhKJp2GQ== '/*!*/; ### INSERT INTO `test`.`t` ### SET ### @1=3 /* INT meta=0 nullable=1 is_null=0 */ ### @2='haha' /* VARSTRING(30) meta=30 nullable=1 is_null=0 */ ### @3='llala' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */ # at 556 #170713 14:44:02 server id 1 end_log_pos 587 CRC32 0x6184a9a1 Xid = 47 COMMIT/*!*/; # at 587 #170713 14:44:16 server id 1 end_log_pos 652 CRC32 0xc585d273 Anonymous_GTID last_committed=2 sequence_number=3 SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; # at 652 #170713 14:44:16 server id 1 end_log_pos 724 CRC32 0x63005380 Query thread_id=8 exec_time=0 error_code=0 SET TIMESTAMP=1499928256/*!*/; BEGIN /*!*/; # at 724 #170713 14:44:16 server id 1 end_log_pos 773 CRC32 0x2c52eaa1 Table_map: `test`.`t` mapped to number 498 # at 773 #170713 14:44:16 server id 1 end_log_pos 816 CRC32 0xa80bd454 Delete_rows: table id 498 flags: STMT_END_F BINLOG ' wBZnWRMBAAAAMQAAAAUDAAAAAPIBAAAAAAEABHRlc3QAAXQAAwMP/AMeAAIHoepSLA== wBZnWSABAAAAKwAAADADAAAAAPIBAAAAAAEAAgAD//wBAAAAAmRkVNQLqA== '/*!*/; ### DELETE FROM `test`.`t` ### WHERE ### @1=1 /* INT meta=0 nullable=1 is_null=0 */ ### @2='dd' /* VARSTRING(30) meta=30 nullable=1 is_null=0 */ ### @3=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */ # at 816 #170713 14:44:16 server id 1 end_log_pos 847 CRC32 0x9d03bcd0 Xid = 48 COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; DELIMITER ; # End of log file /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
“mysql的二进制日志是怎样保存的”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!
新闻标题:mysql的二进制日志是怎样保存的
网址分享:http://azwzsj.com/article/iepghp.html