博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL错误ERROR 1786 (HY000)解决
阅读量:6954 次
发布时间:2019-06-27

本文共 1482 字,大约阅读时间需要 4 分钟。

务上需要支持create table XXX as select * from XXX; 这种创建表的语法,但是MySQL5.7.x版本里面gtid是开启的,会报错

ERROR 1786 (HY000):Statement violates GTID consistency: CREATE TABLE ... SELECT.

官方说明:

CREATE TABLE ... SELECT statements.  CREATE TABLE ... SELECT is not safe for statement-based replication. When using row-based replication, this statement is actually logged as two separate events—one for the creation of the table, and another for the insertion of rows from the source table into the new table just created. When this statement is executed within a transaction, it is possible in some cases for these two events to receive the same transaction identifier, which means that the transaction containing the inserts is skipped by the slave. Therefore, CREATE TABLE ... SELECT is not supported when using GTID-based replication.

解决办法关闭GTID模式:

my.cnf里面修改参数为:

gtid_mode = OFFenforce_gtid_consistency = OFF

重启MySQL,再次创建成功:

mysql> show variables like '%gtid_mode%'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | gtid_mode | OFF | +---------------+-------+ 1 row in set (0.01 sec) mysql> show variables like '%enforce_gtid_consistency%'; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | enforce_gtid_consistency | OFF | +--------------------------+-------+ 1 row in set (0.01 sec) mysql> create table t1 as select * from BS_CONT; Query OK, 0 rows affected (0.12 sec)

转载于:https://www.cnblogs.com/Qing-840/p/9913610.html

你可能感兴趣的文章
dfs的返回条件
查看>>
ASP.NET中Web.Config配置文件详解与应用
查看>>
Django之分页
查看>>
使用wkhtmltopdf的一些事情
查看>>
万达 恒大 万科
查看>>
【 OJ 】Score
查看>>
离开当当
查看>>
各种同步方法性能比较(synchronized,ReentrantLock,Atomic)
查看>>
idea报错项积累
查看>>
Express踩坑系列之初识Express
查看>>
不使用c的任何库函数 实现字符串到整数的转换 整数到字符串的转换
查看>>
Android BCM4330 蓝牙BT驱动调试记录
查看>>
mysql8.0.13安装
查看>>
[原创] Debian9上配置软件阵列
查看>>
远程控制数据库实用SQL重启功能
查看>>
svn备份一般采用三种方式
查看>>
回顾2012,展望2013
查看>>
原创《分享(Angular 和 Vue)按需加载的项目实践优化方案》
查看>>
实现一个单隐层神经网络
查看>>
关于Ajax
查看>>