萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> mysqlbinlog把mysql二進制文件轉換文本文件

mysqlbinlog把mysql二進制文件轉換文本文件

mysqlbinlog命令是mysql中的一個恢復mysql數據庫的工具了,下面本文章再次來為各位介紹利用mysqlbinlog來恢復mysql二進制日志的例子。

目前一些項目已經遷移到Mysql5.5,而在mysql5.5中binlog_format為mixed這樣的話,默認情況下的Mysql binary log就是base64格式,不可讀,為了在排查問題時候,提供幫助研讀下mysqlbinlog的幫助文檔得知可以解碼:

  –base64-output[=name]
Determine when the output statements should be
base64-encoded BINLOG statements: ’never’ disables it and
works only for binlogs without row-based events;
 ’decode-rows’ decodes row events into commented SQL
                      statements if the –verbose option is also given; ’auto’
prints base64 only when necessary (i.e., for row-based
events and format description events); ’always’ prints
base64 whenever possible. ’always’ is deprecated, will be
removed in a future version, and should not be used in a
production system.  –base64-output with no ’name’
argument is equivalent to –base64-output=always and is
also deprecated.  If no –base64-output[=name] option is
given at all, the default is ’auto’.
mysqlbinlog –base64-output=DECODE-ROWS -v mysql-bin.00002

通過給定–base64-output和-v參數,可以解碼row模式下的binary log。

unknown variable ‘default-character-set=utf8mb4′錯誤

一個手機網的項目,使用的編碼為utf8mb4,一切都是正常的。

到了用mysqlbinlog的時候,提示如下:

[root@localhost data]# mysqlbinlog mysql-bin-500.000011
mysqlbinlog: unknown variable ‘default-character-set=utf8mb4′

解決方法:

1. 修改my.cnf,在[client]下注釋或刪除default-character-set=utf8mb4;
2. 在命令行中加入–no-defaults開關,使用mysqlbinlog –no-defaults;

copyright © 萬盛學電腦網 all rights reserved