내일배움캠프 TIL (230316): MySQL sql_mode ONLY_FULL_GROUP_BY 에러 해결

Jiumn·2023년 4월 1일
0

Expression #10 of SELECT list is not in GROUP BY clause and contains nonaggregated column '컬럼 명' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 에러

Expression #10 of SELECT list is not in GROUP BY clause and contains nonaggregated column '컬럼명' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

해석하면

SELECT 목록의 식 #10이 GROUP BY 절에 없으며 GROUP BY 절의 열에 기능적으로 종속되지 않는 집계되지 않은 열 '컬럼명'이 포함되어 있습니다. 이는 sql_mode=only_full_group_by와 호환되지 않습니다

해당 에러는 sql_mode가 켜져 있을 때 only_full_group_by 설정에 맞지 않는 쿼리가 실행되면 발생하는 에러다.

(MySQL 5.7 버전 이후 발생한다고 한다.)

sql_mode가 켜져 있는지 확인하려면 SELECT @@sql_mode; 명령어를 실행해본다.

위와 같은 결과가 나오면 sql_mode가 실행되고 있는 것이다.
분명히 8일 전쯤 같은 에러가 발생해서 sql_mode를 끄는 명령어를 실행했는데 다시 발생했다.

해결 방법

쿼리를 수정해서 해결하는 방법도 있으나 나는 sql_mode를 끄는 방법을 선택했다.

MySQL 콘솔에서 관리자로 로그인하여 ONLY_FULL_GROUP_BY 를 비활성화해주는 명령어를 입력한다.

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
profile
Back-End Wep Developer. 꾸준함이 능력이다.

0개의 댓글