解决mysql利用二进制日志恢复数据报错:ERROR 1781 (HY000) at line 16: @@SESSION.GTID_NEXT cannot be set to UUID:NUMBER when @@GLOBAL.GTID_MODE = OFF.
工作中,运用二进制日志,帮开发的同事恢复数据时,出现了报错告警:
[root@localhost tmp]# mysqlbinlog --no-defaults mysql-bin.000614|mysql -uroot -p Enter password: ERROR 1781 (HY000) at line 16: @@SESSION.GTID_NEXT cannot be set to UUID:NUMBER when @@GLOBAL.GTID_MODE = OFF. [root@localhost tmp]# mysqlbinlog --no-defaults mysql-bin.000614|mysql -uroot -p Enter password: [root@localhost tmp]# echo $? 0 服务器相关环境参数:
服务器系统:CentOS Linux release 7.3.1611 (Core)
MySQL版本:
mysql> select version(); +-----------+ | version() | +-----------+ | 5.7.13 | +-----------+ 1 row in set (0.00 sec) 解决办法:
配置gtid选项
配置前:
mysql> show global variables like 'gtid_mode'; ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection id: 24 Current database: gold +---------------+-------+ | Variable_name | Value | +---------------+-------+ | gtid_mode | OFF | +---------------+-------+ 1 row in set (0.10 sec) 配置后:
mysql> set @@GLOBAL.GTID_MODE = on; ERROR 1788 (HY000): The value of @@GLOBAL.GTID_MODE can only be changed one step at a time: OFF <-> OFF_PERMISSIVE <-> ON_PERMISSIVE <-> ON. Also note that this value must be stepped up or down simultaneously on all servers. See the Manual for instructions. mysql> set @@GLOBAL.GTID_MODE = OFF_PERMISSIVE; mysql> show global variables like 'gtid_mode'; +---------------+----------------+ | Variable_name | Value | +---------------+----------------+ | gtid_mode | OFF_PERMISSIVE | +---------------+----------------+ 1 row in set (0.00 sec) GTID相关知识: