日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 对部分表binlog_MySQL抑制binlog日志中的binlog部分

發布時間:2025/3/15 数据库 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 对部分表binlog_MySQL抑制binlog日志中的binlog部分 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MySQL通過binlog來記錄整個數據的變更過程,因此我們只要有MySQL的binlog日志即可完整的還原數據庫。MySQL binlog日志記錄有3種不同的方式,即:STATEMENT,MIXED,ROW。對于不同的日志模式,生成的binlog有不同的記錄方式。對于MIXED(部分SQL語句)和ROW模式是以base-64方式記錄,會以BINLOG開頭,是一段偽SQL,我們可以用使用base64-output參數來抑制其顯示。本文對此給出了描述及演示。

1、mysqlbinlog之base64-output參數

This option determines when events should be displayed encoded as base-64 strings usingBINLOGstatements. The option has these permissible values (not case sensitive):

AUTO("automatic") orUNSPEC("unspecified") displaysBINLOGstatements automatically when necessary (that is, for format description events and row events). If no--base64-outputoption is given, the effect is the same as--base64-output=AUTO.

NEVERcausesBINLOGstatements not to be displayed.mysqlbinlogexits with an error if a row event is found that must be displayed usingBINLOG.

DECODE-ROWSspecifies tomysqlbinlogthat you intend for row events to be decoded and displayed as commented SQL statements by also specifying the--verboseoption.LikeNEVER,DECODE-ROWSsuppresses display ofstatements, but unlikeNEVER, it does not exit with an error if a row event is found.

以上描述對于binlog日志中的BINLOG部分,如果要過慮掉需要指定DECODE-ROWS以及--verbose選項。

The SQL statements produced by--verbosefor row events are much more readable than the correspondingBINLOGstatements.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, whereNis 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 (BINARYandCHAR,VARBINARYandVARCHAR,BLOBandTEXT). The output uses a data type ofSTRINGfor fixed-length strings andVARSTRINGfor 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 typeUPDATE_ROWS_EVENT,UPDATEstatements are displayed with theWHEREclause preceding theSETclause.

Proper interpretation of row events requires the information from the format description event at the beginning of the binary log. Becausemysqlbinlogdoes not know in advance whether the rest of the log contains row events, by default it displays the format description event using aBINLOGstatement in the initial part of the output.

If the binary log is known not to contain any events requiring aBINLOGstatement (that is, no row events), the--base64-output=NEVERoption 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日志#未使用base64-output選項的情形,即缺省值為AUTO

SHELL>? mysqlbinlog /opt/data/APP01bin.000001|grep truncate -B15

# at 310

#141218 16:28:05 server id 11? end_log_pos 358 CRC32 0xe0025004? ? ? ? Table_map: `test`.`t1` mapped to number 74

# at 358

#141218 16:28:05 server id 11? end_log_pos 402 CRC32 0x3452dcfe? ? ? ? Write_rows: table id 74 flags: STMT_END_F

BINLOG '? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #這個BINLOG部分是真實的SQL語句,無法看到具體內容

FZCSVBMLAAAAMAAAAGYBAAAAAEoAAAAAAAEABHRlc3QAAnQxAAICDwI8AAMEUALg

FZCSVB4LAAAALAAAAJIBAAAAAEoAAAAAAAEAAgAC//wBAAVyb2Jpbv7cUjQ=

'/*!*/;

# at 402

#141218 16:28:05 server id 11? end_log_pos 433 CRC32 0xbe26740a? ? ? ? Xid = 30

COMMIT/*!*/;

# at 433

#141218 16:29:00 server id 11? end_log_pos 517 CRC32 0x89c52d6a? ? ? ? Query? thread_id=1? ? exec_time=0? ? error_code=0

SET TIMESTAMP=1418891340/*!*/;

truncate table t1

#使用-v參數的情形,可以看到我們操作生成的SQL語句了,為insert into之類的形式,如果-vv則輸出列的描述信息

#BINLOG部分依舊被顯示出來

SHELL>? mysqlbinlog -v /opt/data/APP01bin.000001|grep truncate -B20

/*!*/;

# at 310

#141218 16:28:05 server id 11? end_log_pos 358 CRC32 0xe0025004? ? ? ? Table_map: `test`.`t1` mapped to number 74

# at 358

#141218 16:28:05 server id 11? end_log_pos 402 CRC32 0x3452dcfe? ? ? ? Write_rows: table id 74 flags: STMT_END_F

BINLOG '

FZCSVBMLAAAAMAAAAGYBAAAAAEoAAAAAAAEABHRlc3QAAnQxAAICDwI8AAMEUALg

FZCSVB4LAAAALAAAAJIBAAAAAEoAAAAAAAEAAgAC//wBAAVyb2Jpbv7cUjQ=

'/*!*/;

### INSERT INTO `test`.`t1`

### SET

###? @1=1

###? @2='robin'

# at 402

#141218 16:28:05 server id 11? end_log_pos 433 CRC32 0xbe26740a? ? ? ? Xid = 30

COMMIT/*!*/;

# at 433

#141218 16:29:00 server id 11? end_log_pos 517 CRC32 0x89c52d6a? ? ? ? Query? thread_id=1? ? exec_time=0? ? error_code=0

SET TIMESTAMP=1418891340/*!*/;

truncate table t1

#添加--base64-output=DECODE-ROWS選項來抑制BINLOG的顯示,如下我們看不到了BINLOG部分

SHELL>? mysqlbinlog --base64-output=DECODE-ROWS -v /opt/data/APP01bin.000001|grep truncate -B20

/*!*/;

# at 238

#141218 16:28:05 server id 11? end_log_pos 310 CRC32 0x60507739? ? ? ? Query? thread_id=1? ? exec_time=0? ? error_code=0

SET TIMESTAMP=1418891285/*!*/;

BEGIN

/*!*/;

# at 310

#141218 16:28:05 server id 11? end_log_pos 358 CRC32 0xe0025004? ? ? ? Table_map: `test`.`t1` mapped to number 74

# at 358

#141218 16:28:05 server id 11? end_log_pos 402 CRC32 0x3452dcfe? ? ? ? Write_rows: table id 74 flags: STMT_END_F

### INSERT INTO `test`.`t1`

### SET

###? @1=1

###? @2='robin'

# at 402

#141218 16:28:05 server id 11? end_log_pos 433 CRC32 0xbe26740a? ? ? ? Xid = 30

COMMIT/*!*/;

# at 433

#141218 16:29:00 server id 11? end_log_pos 517 CRC32 0x89c52d6a? ? ? ? Query? thread_id=1? ? exec_time=0? ? error_code=0

SET TIMESTAMP=1418891340/*!*/;

truncate table t1

#此時使用mysqlbinlog做一個不完全恢復

SHELL>? mysqlbinlog --database=test --start-position="238" --stop-position="433" /opt/data/APP01bin.000001 |mysql -uroot -p --database=test

Enter password:

#查看恢復后的結果

SHELL>? mysql -uroot -p -e "select * from test.t1"

Enter password:

+------+-------+

| id? | val? |

+------+-------+

|? ? 1 | robin |

+------+-------+

總結

以上是生活随笔為你收集整理的mysql 对部分表binlog_MySQL抑制binlog日志中的binlog部分的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 91视频最新 | 91久久国产综合久久 | 91在线观| 思思久久99 | 黄色免费看片 | 天堂成人在线视频 | 天天射夜夜爽 | 国产一区二区三区高清视频 | 91私密视频| 久久aⅴ国产欧美74aaa | 96av视频| 国产情侣在线播放 | 69xxx国产 | 国外成人免费视频 | 五月天伊人网 | 小泽玛利亚一区二区三区 | 女十八毛片 | 国产无套内射又大又猛又粗又爽 | 免费国产高清 | 美女热逼| 亚洲a黄| 午夜影院网站 | 久久精品99北条麻妃 | 欧美日韩一区二区三区69堂 | 视频国产在线 | 韩国精品在线观看 | 亚洲一区二区三区播放 | 亚洲色图27p | 日本美女黄色大片 | 亚洲av毛片成人精品 | 向日葵视频在线播放 | 双乳被四个男人吃奶h文 | 国产精选中文字幕 | 久久伊人中文字幕 | 亚洲免费福利 | 日日鲁鲁鲁夜夜爽爽狠狠视频97 | 亚洲AV无码一区二区伊人久久 | 丰满圆润老女人hd | 欧美精品在欧美一区二区 | 瑟瑟视频网站 | 特种兵之深入敌后高清全集免费观看 | 欧美福利网址 | 亚洲成人黄色在线 | 超碰av在线免费观看 | 丝袜一区二区三区 | 精品一区二区三区毛片 | 黄色一级a毛片 | 亚洲男人天堂网址 | 久久青娱乐 | 国产精品成人一区二区网站软件 | 女人高潮被爽到呻吟在线观看 | www国产黄色 | 网站久久 | 老熟女一区二区三区 | 成人爽a毛片一区二区 | 黄频在线播放 | 亚洲欧美不卡 | 国产精品视频专区 | 黄色无遮挡网站 | 国产制服91一区二区三区制服 | 2025国产精品视频 | 日韩美女爱爱 | 日本a一级片 | 欧美大片在线免费观看 | 亚洲日批| 96精品在线 | 中国老太婆性做爰 | 日本三级黄色录像 | 欧美h视频在线观看 | 亚洲精品国产suv一区 | 亚洲视频123 | 91综合网 | 亚洲精品久久久蜜桃 | 伊人资源网 | 国产理论片在线观看 | 97国产精品视频人人做人人爱 | 黑人巨大精品一区二区在线 | 久久久久久久久久久久久久国产 | 国产乱码在线 | 欧美日韩一区二 | 国产男人搡女人免费视频 | 操老女人视频 | 亚洲蜜桃av一区二区 | 国产精品婷婷 | 四川黄色一级片 | fc2ppv在线观看 | 日韩精品久久 | 中文字幕免费在线视频 | 色啪综合| 亚洲免费成人 | 一本大道av伊人久久综合 | 亚洲黄色免费网站 | av网址免费在线观看 | 狠狠人妻久久久久久综合 | 白白色免费视频 | 亚洲最大av在线 | 男人天堂a在线 | 97视频在线看 | 国产精品无码av在线有声小说 |