天天看點

mysql sql_mode問題

最近項目中出現了

this is incompatible with sql_mode=only_full_group_by
           

這個問題,百度之,全是修改my.cnf檔案,本機沒有這個檔案,

vi /etc/my.cnf 
           

建立,然後,mysql動不了了,嗯~這個方法不适用。

又試了方案二:

[email protected]@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
           

,然後出現了

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUT' at line 1
           

不行,解決不了,最後參照https://www.cnblogs.com/fireporsche/p/8618691.html這篇解析,

set @@global.sql_mode=(select replace(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', ''));
           

這樣一句話就解決了,隻能說,試了才知道,記錄一下。

繼續閱讀