Disable ONLY_FULL_GROUP_BY

后端 未结 27 1304
既然无缘
既然无缘 2020-11-22 00:22

I accidentally enabled ONLY_FULL_GROUP_BY mode like this:

SET sql_mode = \'ONLY_FULL_GROUP_BY\';

How do I disable it?

相关标签:
27条回答
  • 2020-11-22 01:17

    For Mac OS Mojave (10.14) Open terminal

    $ sudo mkdir /usr/local/mysql-5.7.24-macos10.14-x86_64/etc
    $ cd /usr/local/mysql-5.7.24-macos10.14-x86_64/etc
    $ sudo nano my.cnf
    

    Paste following:

    [mysqld]
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
    

    Shortkeys to Save & Exit nano: Ctrl+x and y and Enter

    Note: You might need to update mysql-5.7.24-macos10.14-x86_64 in these commands, just check the correct folder name you got within /usr/local/

    Hope it will help someone!

    0 讨论(0)
  • 2020-11-22 01:18

    Im working with mysql and registered with root user, the solution that work for me is the following:

    mysql > SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

    0 讨论(0)
  • 2020-11-22 01:18

    As of MySQL 5.7.x, the default sql mode includes ONLY_FULL_GROUP_BY. (Before 5.7.5, MySQL does not detect functional dependency and ONLY_FULL_GROUP_BY is not enabled by default).

    ONLY_FULL_GROUP_BY: Non-deterministic grouping queries will be rejected

    For more details check the documentation of sql_mode

    You can follow either of the below methods to modify the sql_mode

    Method 1:

    Check default value of sql_mode:

    SELECT @@sql_mode
    

    Remove ONLY_FULL_GROUP_BY from console by executing below query:

    SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
    

    Method 2:

    Access phpmyadmin for editing your sql_mode

    • Login on phpmyadmin and open localhost
    • Top on Variables present on the top in menu items and search out for sql mode
    • Click on edit button to remove ONLY_FULL_GROUP_BY and save
    0 讨论(0)
提交回复
热议问题