当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL读取Binlog日志常见的3种错误

MySQL读取Binlog日志常见的3种错误

2019年04月28日  | 移动技术网IT编程  | 我要评论

1. mysqlbinlog: [error] unknown variable 'default-character-set=utf8mb4'

当我们在my.cnf中添加default-character-set=utf8mb4选项,那么在mysqlbinlog查看binlog时就会报错。

 

解决方案:.mysqlbinlog 后面添加 --no-defaults 选项

例如:

mysql bin可执行文件所在路径/bin/mysqlbinlog --no-defaults binlog所在目录/mysql_bin.000005

 

2.error 1840 (hy000) at line 24: @@global.gtid_purged can only be set when @@global.gtid_executed is empty.

在进行mysqldump导出数据,进行数据库迁移。而在迁入时,报了上面的错误。

查询原因是 :当前gtid_executed参数已经有值,而从源数据库中倒出来的dump文件中包含了set @@global.gtid_purged的操作

解决方法:

方法一:reset mater

这个操作可以将当前库的gtid_executed值置空

方法二:--set-gtid-purged=off

在dump导出时,添加--set-gtid-purged=off参数,避免将gtid信息导出

mysqldump  --set-gtid-purged=off -d dbtest > dbtest.sql

 

3.error 1782 (hy000) at line 23: @@session.gtid_next cannot be set to anonymous when @@global.gtid_mode = on.

当我们在使用 mysqlbinlog 工具进行 指定--stop-position 、--start-position 进行恢复(部分恢复)时报的错。

例如,binlog中的数据如下:

 

当我们选择的开始点是  query 对应的 pos (713),,而不是 gtid对应的pos(648)就会报错。

下面的写法报错:

安装路径/bin/mysqlbinlog  --no-defaults --start-position=713 --stop-position=1646

下面的写法没有报错:

 安装路径/bin/mysqlbinlog  --no-defaults --start-position=648 --stop-position=1646 .........

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网