参考文档:
 
总共有6个过滤规则:
1  --replicate-do-db
2  --replicate-ignore-db
3  --replicate-do-table
4  --replicate-wild-do-table
5  --replicate-ignore-table
6  --replicate-wild-ignore-table
 
以上6个规则的前2个是库级别的规则,后4个是表级别的规则。使用注意点:
1:库级别的规则,只针对binlog_format='STATEMENT'或'MIXED'。
2:如果是binlog_format='ROW',不受库级别规则限制,只受表级别规则限制。
3:表级别的规则,针对所有模式。
4:binlog_format='STATEMENT'或者'MIXED'时,记录use 语句,此时如果使用 --replicate-do-db,则不支持跨库修改。
    如use test; update db1 set …… 这里判断的是use 后面的test库,所以updte语句不执行。建议使用--replicate-wild-do-table
5:binlog_format='ROW'时,不记录use语句。只受表级别规则的影响。只能配置后面四条规则。
 
测试不同模式下binlog记录情况:
 
执行sql:
set global binlog_format='row';
use test;
update db1.t2 set name='a200' where id=105;
use db1;
 
记录的binlog如下:
 /*!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
#170808 0:49:08 server id 1882073306 end_log_pos 120 CRC32 0xbddf73ce Start: binlog v 4, server v 5.6.23-72.1-log created 170808 0:49:08
# Warning: this binlog is either in use or was not closed properly.
# at 120
#170808 0:50:16 server id 1882073306 end_log_pos 191 CRC32 0xb2586cef Query thread_id=73 exec_time=0 error_code=0
SET TIMESTAMP=1502124616/*!*/;
SET @@session.pseudo_thread_id=73/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1073741824/*!*/;
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/*!*/;
BEGIN
/*!*/;
# at 191
#170808 0:50:16 server id 1882073306 end_log_pos 245 CRC32 0xe7585ab8 Table_map: `db1`.`t2` mapped to number 395
# at 245
#170808 0:50:16 server id 1882073306 end_log_pos 365 CRC32 0x86dbbb24 Update_rows: table id 395 flags: STMT_END_F
### UPDATE `db1`.`t2`
### WHERE
### @1=105 /* INT meta=0 nullable=0 is_null=0 */
### @2='a100' /* VARSTRING(90) meta=90 nullable=0 is_null=0 */
### @3='57747ab889255af96b48d65e505382' /* VARSTRING(90) meta=90 nullable=0 is_null=0 */
### @4='' /* VARSTRING(72) meta=72 nullable=0 is_null=0 */
### @5=NULL /* VARSTRING(72) meta=0 nullable=1 is_null=1 */
### SET
### @1=105 /* INT meta=0 nullable=0 is_null=0 */
### @2='a200' /* VARSTRING(90) meta=90 nullable=0 is_null=0 */
### @3='57747ab889255af96b48d65e505382' /* VARSTRING(90) meta=90 nullable=0 is_null=0 */
### @4='' /* VARSTRING(72) meta=72 nullable=0 is_null=0 */
### @5=NULL /* VARSTRING(72) meta=0 nullable=1 is_null=1 */
# at 365
#170808 0:50:16 server id 1882073306 end_log_pos 396 CRC32 0x99f0e5d3 Xid = 32212
COMMIT/*!*/;
 
执行sql:
set global binlog_format='mixed';
use test;
update db1.t2 set name='a300' where id=105;
use db1;
 
记录的binlog如下:
 # at 396
#170808 0:53:14 server id 1882073306 end_log_pos 474 CRC32 0x46f75d21 Query thread_id=74 exec_time=0 error_code=0
SET TIMESTAMP=1502124794/*!*/;
BEGIN
/*!*/;
# at 474
#170808 0:53:14 server id 1882073306 end_log_pos 589 CRC32 0x7193484c Query thread_id=74 exec_time=0 error_code=0
use `test`/*!*/;
SET TIMESTAMP=1502124794/*!*/;
update db1.t2 set name='a300' where id=105
/*!*/;
# at 589
#170808 0:53:14 server id 1882073306 end_log_pos 620 CRC32 0xc3e0c9e3 Xid = 32328
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

最新文章

  1. 【转载】VS2012的打包方法
  2. 【分享】国外后台界面HTML源码 [免费]
  3. 报错mongoose.connection.db.collectionnames is not a function
  4. docker在ubuntu14.04下的安装笔记
  5. css让元素居中显示
  6. 搜索框js样式(通用型)
  7. UIAutomator 编译
  8. python中的 zip函数详解
  9. ComboBox控件
  10. python Post方式发起http请求 使用百度接口地理编码
  11. java利用WatchService实时监控某个目录下的文件变化并按行解析(注:附源代码)
  12. Django开发基础----创建项目/应用
  13. MongoDB+php7搭建
  14. 移除SharePoint2013里的NoteBook笔记本链接
  15. 制作windows服务
  16. WinForm界面开发之 启动界面
  17. Egret类class和module写法区别
  18. ArrayList 和 Vector 的区别
  19. ASP.NET MVC 下拉列表实现
  20. 【原创】Eclipse中Android项目引用

热门文章

  1. 【Android归纳】回调机制在Android中的应用与实战
  2. js算法:分治法-循环赛事日程表
  3. lamdba匿名函数 sored()函数 filter()函数 map函数() 递归函数
  4. 【bzoj4538】[Hnoi2016]网络
  5. libXdmcp.so.6
  6. flash、flex builder、flash builder、 air的关系
  7. Win7 64 位 vs2012 pthread 配置
  8. 关于mysql的索引原理与慢查询优化
  9. Java多线程系列二——Thread类的方法
  10. sqlserver2005连接失败,不存在或拒绝访问