mysqlbinlog命令是mysql中的一个恢复mysql数据库的工具了,下面本文章再次来为各位介绍利用mysqlbinlog来恢复mysql二进制日志的例子.
目前一些项目已经迁移到Mysql5.5,而在mysql5.5中binlog_format为mixed这样的话,默认情况下的Mysql binary log就是base64格式,不可读,为了在排查问题时候,提供帮助研读下mysqlbinlog的帮助文档得知可以解码:
- –base64-output[=name]
- Determinewhentheoutputstatementsshouldbe
- base64-encodedBINLOGstatements:’never’disablesitand
- worksonlyforbinlogswithoutrow-basedevents;
- ’decode-rows’decodesroweventsintocommentedSQL
- statementsifthe–verboseoptionisalsogiven;’auto’
- printsbase64onlywhennecessary(i.e.,forrow-based
- eventsandformatdescriptionevents);’always’prints
- base64wheneverpossible.’always’isdeprecated,willbe
- removedinafutureversion,andshouldnotbeusedina
- productionsystem.–base64-outputwithno’name’
- //开源代码phpfensi.com
- argumentisequivalentto–base64-output=alwaysandis
- alsodeprecated.Ifno–base64-output[=name]optionis
- givenatall,thedefaultis’auto’.
- mysqlbinlog–base64-output=DECODE-ROWS-vmysql-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;