1. 程式人生 > >Expression #1 of ORDER BY clause is not in GROUP BY clause...

Expression #1 of ORDER BY clause is not in GROUP BY clause...

問題描述:

在mysql客戶端執行delete刪除語句時,報出了以下錯誤:

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and 
contains nonaggregated column 'information_schema.PROFILING.SEQ' 
which is not functionally dependent on columns in GROUP BY clause; 
this is incompatible with sql_mode=only_full_group_by
查詢MySQL版本為:5.7.18
select version() from dual;
經過搜尋後,得到以下解決方案:

1. 使用find命令查詢名為my.cnf的檔案

# find / -name my.cnf
2. 使用vi命令編輯該檔案,增加以下語句:
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
最終部分程式碼如下所示:
character-set-server=utf8mb4
lower_case_table_names=1

skip-host-cache
skip-name-resolve

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

[client]
default-character-set=utf8mb4
3. 儲存後, 重啟mysql服務
# service mysqld restart
解決收工.