본문 바로가기
투닥투닥

mysql 1055 (42000) Error

by Lauren X Ming 2022. 6. 7.
1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'webapp.webapp_mandatory.config' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

이런 에러 만났을때

mysql -h localhost -u root -p
  • mysql 접속
mysql> show variables like 'sql_mode';
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value                                                                                                                                     |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| sql_mode      | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
  • show variables like 'sql_mode'; 로 현재 설정된 값 확인
mysql> 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';
  • 위에서 확인한 것들 중 ONLY_FULL_GROUP_BY 제외하고 나머지 값 다시 세팅

 

이걸로 해도 안되면

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));