当前位置:Gxlcms > 数据库问题 > mysqlbinlog 使用简介

mysqlbinlog 使用简介

时间:2021-07-01 10:21:17 帮助过:9人阅读

(即二进制格式和语句格式)。

如果没有--base64-output 选项给出的效果与 --base64-output=AUTO 相同。


--start-datetime=name 

                      开始读取binlog日志的指定时间,时区是日志本地时区,时间格式例子‘2016-12-25 11:25:56 ’(要使用引号,避免shell里识别出错。)


 --stop-datetime=name 

                     停止读取binlog日志的指定时间,时区是日志本地时区,时间格式例子‘2016-12-25 11:25:56 ’(要使用引号,避免shell里识别出错。)

  

--start-position=# 

                     开始读取 binlog 日志在 指定position号码. 读取范围更精准,可以避免时区错误,恢复数据时建议使用。


  --stop-position=#   

                    停止读取 binlog 日志在 指定position号码. 读取范围更精准,可以避免时区错误,恢复数据时建议使用。


  -v    从行事件中重建伪 sql 语句。


  -vv  从行事件中重建伪 sql 语句,添加对数据类型的注释。


--database=name

   指定导出的数据库


--skip-gtids 

   输出时忽略全局事物ID号码。


导出时间范围内的binlog日志,从行事件中重建伪sql 语句,使用Sql语句编码,如果有多个binlog文件,后续使用>>添加到导出文件,尽量使用绝对路径。

mysqlbinlog -v --base64-output=decode-rows --start-datetime=‘2016-12-25 11:25:56‘ --stop-datetime=‘2016-12-25 11:59:59‘ binlogname > filename.sql


捉取准确的position号码范围,导出sql文件。

mysqlbinlog --start-position=10000 --stop-position=20000 binlogname > filename.sql


mysql进行数据导入。

mysql -u‘user‘ -p‘password‘ < filename.sql #危险操作!!!


参考资料:

1,RDS Mysql中binlog日志查看  https://help.aliyun.com/knowledge_detail/41709.html

2,mysqlbinlog官方手册 https://dev.mysql.com/doc/refman/5.7/en/mysqlbinlog.html


本文出自 “专注打孔100年” 博客,请务必保留此出处http://titandeng.blog.51cto.com/823817/1945303

mysqlbinlog 使用简介

标签:mysql   binlog   

人气教程排行