Character set ‘#45′ 导致主从停止问题
搭建主从环境时,从库 Slave_IO_Running 停止,Last_Error 提示 mysqlbinlog 报错:Character set '#45' is not a compiled character set,且未在 Index.xml 中指定。用 mysqlbinlog 解析对应 relaylog 同样报错。查看 Index.xml 发现该 server 并没有 id 为 45 的字符集,slave 同步时解析出错导致同步中断。从 binlog 中的 SET @@session.character_set_client=45 可以看出,是有用户连接 master 后执行了 set names,被翻译成了字符集编号 45。在 5.5 上查询确认该编号对应的正是 utf8mb4,而这个字符集在 5.1 中尚未存在。
结论是在高版本 master 同步到低版本 slave 的场景下,要注意不要使用低版本不支持的字符集,官方也并不建议这种配置。对于 master 中已存在的 binlog,若要让主从继续同步,只能在 slave_skip_errors 中加入 22 这个错误号跳过。