Home > Mobile >  SQL_MODE error keeps coming back even after using SET sql_mode
SQL_MODE error keeps coming back even after using SET sql_mode

Time:03-23

My back is giving me the usual:

...not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

I'm using mysql as a container, and I tried set sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; in all databases, for all users... And the error remains the same... Don't know what to do

CodePudding user response:

You could run

SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

And fix the problem temporary , but after MySQL restart the default settings will come back.

You need to set on your .cnf file below line and restart the MySQL server. Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf .

[mysqld]
sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

I suggest better fix the queries rather than removing only_full_group_by

  • Related