【MySQL案例】ERROR 1786 (HY000)

來源:互聯網
上載者:User

1.1.1. ERROR 1786 (HY000)

【環境描述】

msyql5.6.14

【報錯資訊】

執行create table ... select的時候遇到報錯:

db1 [test] [23:01:58]> create tablelgmnr_bak select * from lgmnr;  

ERROR 1786 (HY000): CREATE TABLE ... SELECTis forbidden when @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1

【報錯原因】

         ERROR1786是由於開啟了enforce_gtid_consistency=true功能導致的,MySQL官方解釋說當啟用enforce_gtid_consistency功能的時候,MySQL只允許能夠保障事務安全,並且能夠被日誌記錄的SQL語句被執行,像create table ... select 和 create temporarytable語句,以及同時更新事務表和非事務表的SQL語句或事務都不允許執行。

 

db1 [test] [23:28:28]> show variableslike 'ENFORCE_GTID_CONSISTENCY';

+--------------------------+-------+

| Variable_name            | Value |

+--------------------------+-------+

| enforce_gtid_consistency | ON    |

+--------------------------+-------+

【解決方案】

由於enforce_gtid_consistency參數是唯讀,所以必須重啟MySQL服務才能是配置生效。

嘗試線上動態修改時的報錯:

db1 [test] [23:37:56]> set globalenforce_gtid_consistency=true;

ERROR 1238 (HY000): Variable'enforce_gtid_consistency' is a read only variable

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.