Disable ONLY_FULL_GROUP_BY

后端 未结 27 1348
既然无缘
既然无缘 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:01

    To whom is running a VPS/Server with cPanel/WHM, you can do the following to permanently disable ONLY_FULL_GROUP_BY

    You need root access (either on a VPS or a dedicated server)

    1. Enter WHM as root and run phpMyAdmin

    2. Click on Variables, look for sql_mode, click on 'Edit' and copy the entire line inside that textbox

    e.g. copy this:

    ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    
    1. Connect to you server via SFTP - SSH (root) and download the file /etc/my.cnf

    2. Open with a text editor my.cnf file on your local PC and paste into it (under [mysqld] section) the entire line you copied at step (2) but remove ONLY_FULL_GROUP_BY,

    e.g. paste this:

    # disabling ONLY_FULL_GROUP_BY
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    
    1. Save the my.cnf file and upload it back into /etc/

    2. Enter WHM and go to "WHM > Restart Services > SQL Server (MySQL)" and restart the service

提交回复
热议问题