python35 ./binlog2sql.py -h... -P... -u... -p... -B --start-file="mysql-bin.091940" --start-position=43669051 --stop-position=65769997 > /export/logs/redo.sql

执行报错

Traceback (most recent call last):
  File "/export/servers/pbmonitor/exps/static/file/mysql_tools/binlog2sql/binlog2sql.py", line 150, in <module>
    binlog2sql.process_binlog()
  File "/export/servers/pbmonitor/exps/static/file/mysql_tools/binlog2sql/binlog2sql.py", line 121, in process_binlog
    self.print_rollback_sql(filename=tmp_file)
  File "/export/servers/pbmonitor/exps/static/file/mysql_tools/binlog2sql/binlog2sql.py", line 129, in print_rollback_sql
    for line in reversed_lines(f_tmp):
  File "/export/servers/pbmonitor/exps/static/file/mysql_tools/binlog2sql/binlog2sql_util.py", line 249, in reversed_lines
    block = block.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte

第249行,修改block.decode为ignore模式

247     for block in reversed_blocks(fin):
248 if PY3PLUS:
249 block = block.decode("utf-8","ignore")
250 for c in reversed(block):
251 if c == '\n' and part:
252 yield part[::-1]
253 part = ''
254 part += c
255 if part:
256 yield part[::-1]

参考

UnicodeDecodeError: 'utf-8' codec can't decode byte..问题

binlog2sql 解析日志失败 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte的更多相关文章

  1. TensorFlow学习笔记(UTF-8 问题解决 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte)

    我使用VS2013  Python3.5  TensorFlow 1.3  的开发环境 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff ...

  2. tensorflow UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

    tensorflow读取图像出现错误:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid s ...

  3. Python:出现UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc9 in position 0: invalid continuation byte问题

    我在导入一个csv文件的时候出现了一个问题 报错的内容是这样的: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc9 in positio ...

  4. Pandas读取文件报错UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

    pandas读取文件时报UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start by ...

  5. TensorFlow学习('utf-8' codec can't decode byte 0xff in position 0: invalid start byte)

    使用语句: image_raw_data = tf.gfile.GFile("./picture.jpg", "r").read() 读取图像时报错如下: Un ...

  6. 读文件时出现这个错误 'utf-8' codec can't decode byte 0xba in position 21: invalid start byte

    ''' file2 文件内容: 很任性wheniwasyoung ''' 源代码: f = open("file2",'r',encoding="utf-8") ...

  7. 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

    'utf-8' codec can't decode byte 0xff in position 0: invalid start byte 觉得有用的话,欢迎一起讨论相互学习~Follow Me 今 ...

  8. 第一篇:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte

    需求:python如何实现普通用户登录服务器后切换到root用户再执行命令 解决参考: 代码: def verification_ssh(host,username,password,port,roo ...

  9. UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte

    需求:python如何实现普通用户登录服务器后切换到root用户再执行命令 解决参考: 代码: def verification_ssh(host,username,password,port,roo ...

随机推荐

  1. Canal 实战 | 第一篇:SpringBoot 整合 Canal + RabbitMQ 实现监听 MySQL 数据库同步更新 Redis 缓存

    一. Canal 简介 canal [kə'næl],译意为水道/管道/沟渠,主要用途是基于 MySQL 数据库增量日志解析,提供增量数据订阅和消费 早期阿里巴巴因为杭州和美国双机房部署,存在跨机房同 ...

  2. c++ 算法 next_permutation

    遇到这个算法是在大牛写的10行的8皇后问题中,下面首先给出这个10行就解决了8皇后的NB代码,我目前还是没有看懂对于皇后不在同一列的判断,因为他巧妙的用了移位操作. #include<iostr ...

  3. Swift学习笔记(一)

    1.Constants and Variables(常量和变量) let定义常量,var定义变量. [Note] If a stored value in your code won't change ...

  4. 13-Semi-supervised Learning

    半监督学习(semi-supervised learning) 1.introduction 2.Semi-supervised Learning for Generative Model 3.Low ...

  5. java中static关键字的解析

    静态的特点: A:随着类的加载而加载 B:优先于对象而存在 C:静态是被所有对象共享的数据 这也是我们来判断是否使用静态的标准 D:静态的出现,让我们的调用方式多了一种 类名.静态的内容 非静态的内容 ...

  6. vue3 + vite实现异步组件和路由懒加载

    在 Vue2 中,异步组件和路由懒加载处理使用 import 就可以很轻松实现.但是在Vue 3.x 中异步组件的使用与 Vue 2.x 完全不同了.本文就详细讲讲vue3中异步组件和路由懒加载的实现 ...

  7. 宝藏好物gRPCurl

    宝物简介 grpcur是一个与grpc服务器交互的命令行工具,可认为是gRPC的curl工具. grpcurl用于从命令行调用gRPC服务器支持的RPC方法,gRPC使用二进制编码(protobuf) ...

  8. 异常处理截止和UML图

    0.异常处理机制 0.1.java中异常的作用是:增强程序健壮性. 0.2.java中异常以类和对象的形式存在. 1.java的异常处理机制 1.1.异常在java中以类和对象的形式存在.那么异常的继 ...

  9. python 配置pip镜像源

    在本地用户下新建pip文件夹,新建pip.ini [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trust ...

  10. 访问ajax请求后的结果

    let getJPM = (function() { let result; let url ="xxx"; $.ajax({ type: "post", ur ...