mysql sql_mode 導致 this is incompatible with sql_mode=only_full_group_by
阿新 • • 發佈:2018-12-17
linux伺服器上的mysql 執行一切正常
在本地mysql 的時候報錯
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY, expression #9 of SELECT list contains nonaggregated column 'yd_2.al.level'; this is incompatible with sql_mode=only_full_group_by
重點是這句this is incompatible with sql_mode=only_full_group_by
翻譯過來大概是在 sql_mode=only_full_group_by 下是不相容的
於是想辦法修改 sql_mode ,
我先看了下自己的mysql版本
是5.7
然後檢視當前sql_mode
修改my.cnf(windows下是my.ini)配置檔案
sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
重啟mysql服務 就可以了
在積累以上經驗之前還試過很多用sql 語句修改sql_model的 沒有成功,至少在我5.7上沒有成功!