項目換了個數據庫報錯:html
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'kjwl.a.description' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_bymysql
主要由於某些 sql group by 語句寫得不規範,且數據庫設置語法規則比較嚴格的時候會報錯。若是不想改 sql 語句則要改 mysql 的設置:sql
sql_mode 中去掉 only_full_group_by 項。數據庫
能夠在 mysql 命令行下輸入 SELECT @@sql_mode; 查看當前 sql_mode 有哪些設置。this
而後能夠執行:命令行
set @@GLOBAL.sql_mode='';htm
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';blog
即重設此值。但這還有一個問題,就是重啓 mysql 後設置會被還原。因此上面設置要放到 mysql 的配置文件中,默認是 /etc/my.cnfip
在 [mysqld] 項下增長(只要裏面沒有only_full_group_by 就好了)get
# to solve problem: this is incompatible with sql_mode=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
網上還有說增長的項寫成像執行命令的語句同樣,但我用本身的版本試則啓動失敗,用上面那種方式就能夠。