danfengcao / binlog2sql

Parse MySQL binlog to SQL you want

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

运行时报错 UnicodeDecodeError

JamesZBL opened this issue · comments

commented
Traceback (most recent call last):
  File "binlog2sql/binlog2sql/binlog2sql.py", line 150, in <module>
    binlog2sql.process_binlog()
  File "binlog2sql/binlog2sql/binlog2sql.py", line 74, in process_binlog
    for binlog_event in stream:
  File "/usr/lib/python2.7/site-packages/pymysqlreplication/binlogstream.py", line 432, in fetchone
    self.__fail_on_table_metadata_unavailable)
  File "/usr/lib/python2.7/site-packages/pymysqlreplication/packet.py", line 139, in __init__
    fail_on_table_metadata_unavailable=fail_on_table_metadata_unavailable)
  File "/usr/lib/python2.7/site-packages/pymysqlreplication/event.py", line 175, in __init__
    - self.schema_length - 1).decode("utf-8")
  File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x97 in position 250: invalid start byte

我出现在解析阿里云mysql ,-B生成回滚SQL时 出现。
我的处理:修改binlog2sql_util.py 第280行:block = block.decode("utf-8", 'ignore')
忽略编码错误,生成的SQL是正确的。