MySQL抑制binlog日志中的BINLOG部分_MySQL
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MySQL抑制binlog日志中的BINLOG部分_MySQL,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含6827字,纯文字阅读大概需要10分钟。
内容图文
![MySQL抑制binlog日志中的BINLOG部分_MySQL](/upload/InfoBanner/zyjiaocheng/580/a5364a9b452347e5a59a13a915e60078.jpg)
有关mysqlbinlog的用法,请参考:使用mysqlbinlog提取二进制日志
1、mysqlbinlog之base64-output参数
--base64-output=value
This option determines when events should be displayed encoded as base-64 strings using BINLOG statements. The option has these permissible values (not case sensitive):
AUTO ("automatic") or UNSPEC ("unspecified") displays BINLOG statements automatically when necessary (that is, for format description events and row events). If no --base64-output option is given, the effect is the same as --base64-output=AUTO. NEVER causes BINLOG statements not to be displayed. mysqlbinlog exits with an error if a row event is found that must be displayed using BINLOG.DECODE-ROWS specifies to mysqlbinlog that you intend for row events to be decoded and displayed as commented SQL statements by also specifying the --verbose option. Like NEVER, DECODE-ROWS suppresses display of BINLOG statements, but unlike NEVER, it does not exit with an error if a row event is found.以上描述对于binlog日志中的BINLOG部分,如果要过虑掉需要指定DECODE-ROWS 以及--verbose选项。
The SQL statements produced by --verbose for row events are much more readable than the corresponding BINLOG statements. However, they do not correspond exactly to the original SQL statements that generated the events. The following limitations apply:
--verbose选项可以获取更多的可读信息,但是并不是一个原始的SQL语句(类似的)。
· The original column names are lost and replaced by @N, where N is a column number.
· Character set information is not available in the binary log, which affects string column display:
There is no distinction made between corresponding binary and nonbinary string types (BINARY and CHAR,VARBINARY and VARCHAR, BLOB and TEXT). The output uses a data type of STRING for fixed-length strings andVARSTRING for variable-length strings.For multibyte character sets, the maximum number of bytes per character is not present in the binary log, so the length for string types is displayed in bytes rather than in characters. For example, STRING(4) will be used as the data type for values from either of these column types:CHAR(4) CHARACTER SET latin1
CHAR(2) CHARACTER SET ucs2
Due to the storage format for events of type UPDATE_ROWS_EVENT, UPDATE statements are displayed with theWHERE clause preceding the SET clause.Proper interpretation of row events requires the information from the format description event at the beginning of the binary log. Because mysqlbinlog does not know in advance whether the rest of the log contains row events, by default it displays the format description event using a BINLOG statement in the initial part of the output.
If the binary log is known not to contain any events requiring a BINLOG statement (that is, no row events), the --base64-output=NEVER option can be used to prevent this header from being written.
2、演示生成binlog日志
--环境 mysql> show variables like 'version'; +---------------+------------+ | Variable_name | Value | +---------------+------------+ | version | 5.6.12-log | +---------------+------------+ --如下查询binlog为row记录模式 mysql> show variables like 'binlog_for%'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | binlog_format | ROW | +---------------+-------+ mysql> reset master; Query OK, 0 rows affected (0.01 sec) mysql> show master status; +-----------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-----------------+----------+--------------+------------------+-------------------+ | APP01bin.000001 | 120 | | | | +-----------------+----------+--------------+------------------+-------------------+ mysql> use test; Database changed --创建表t1 mysql> create table t1(id smallint,val varchar(20)); Query OK, 0 rows affected (0.01 sec) --插入单条记录 mysql> insert into t1 values(1,'robin'); Query OK, 1 row affected (0.00 sec) --清空表 mysql> truncate table t1; Query OK, 0 rows affected (0.01 sec) --查看binlog events mysql> show binlog events; +-----------------+-----+-------------+-----------+-------------+----------------------------------------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +-----------------+-----+-------------+-----------+-------------+----------------------------------------------------------+ | APP01bin.000001 | 4 | Format_desc | 11 | 120 | Server ver: 5.6.12-log, Binlog ver: 4 | | APP01bin.000001 | 120 | Query | 11 | 238 | use `test`; create table t1(id smallint,val varchar(20)) | | APP01bin.000001 | 238 | Query | 11 | 310 | BEGIN | | APP01bin.000001 | 310 | Table_map | 11 | 358 | table_id: 74 (test.t1) | | APP01bin.000001 | 358 | Write_rows | 11 | 402 | table_id: 74 flags: STMT_END_F | | APP01bin.000001 | 402 | Xid | 11 | 433 | COMMIT /* xid=30 */ | | APP01bin.000001 | 433 | Query | 11 | 517 | use `test`; truncate table t1 | +-----------------+-----+-------------+-----------+-------------+----------------------------------------------------------+ 7 rows in set (0.00 sec) --获取binlog位置 mysql> show variables like 'log_bin_basename'; +------------------+--------------------+ | Variable_name | Value | +------------------+--------------------+ | log_bin_basename | /opt/data/APP01bin | +------------------+--------------------+
3、演示提取binlog日志
BINLOG ' #这个BINLOG部分是真实的SQL语句,无法看到具体内容
fzcsvbmlaaaamaaaagybaaaaaeoaaaaaaaeabhrlc3qaanqxaaicdwi8aameualg<br="" >fzcsvb4laaaalaaaajibaaaaaeoaaaaaaaeaagac="" wbaavyb2jpbv7cujq="<br" >'="" *!*="" ;
#使用-v参数的情形,可以看到我们操作生成的SQL语句了,为insert into ..@1之类的形式,如果-vv则输出列的描述信息
BINLOG '
fzcsvbmlaaaamaaaagybaaaaaeoaaaaaaaeabhrlc3qaanqxaaicdwi8aameualg<br="" >fzcsvb4laaaalaaaajibaaaaaeoaaaaaaaeaagac="" wbaavyb2jpbv7cujq="<br" >'="" *!*="" ;
#添加--base64-output=DECODE-ROWS选项来抑制BINLOG的显示,如下我们看不到了BINLOG部分
#此时使用mysqlbinlog做一个不完全恢复
#查看恢复后的结果
内容总结
以上是互联网集市为您收集整理的MySQL抑制binlog日志中的BINLOG部分_MySQL全部内容,希望文章能够帮你解决MySQL抑制binlog日志中的BINLOG部分_MySQL所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。