1267: Illegal mix of collations
MySQL의미
비교나 결합 작업(JOIN, WHERE, UNION, CONCAT)에서 collation이 다른 두 문자열이 결합되어 MySQL이 어떤 collation 규칙을 적용할지 결정할 수 없었다.
원인
보통 문자 집합/collation이 다른 컬럼을 비교하거나(예: utf8mb4_general_ci vs. utf8mb4_unicode_ci, 또는 latin1 vs. utf8mb4), 컬럼과 연결 collation이 일치하지 않는 경우다. 테이블/데이터베이스가 서로 다른 기본값으로 생성되었을 때 흔하다.
해결 방법
비교의 양쪽을 같은 collation으로 맞춘다: COLLATE로 명시적 collation을 지정하거나(예: col1 = col2 COLLATE utf8mb4_unicode_ci) CONVERT(... USING ...)를 사용한다. 영구 조치로 영향을 받는 컬럼/테이블을 하나의 일관된 문자 집합과 collation으로 변환한다. 연결 collation(collation_connection)도 맞춘다.
같은 데이터베이스의 다른 항목
- 3948Loading local data is disabled; this must be enabled on both the client and server sides (로컬 데이터 로드가 비활성화됨. 클라이언트와 서버 양쪽에서 활성화 필요)
- 1075Incorrect table definition; there can be only one auto column and it must be defined as a key (잘못된 테이블 정의. auto 컬럼은 하나만 가능하며 키로 정의해야 함)
- 1055Expression not in GROUP BY (only_full_group_by) (GROUP BY에 없는 표현식)
- 1030Got error N from storage engine
- 1197Multi-statement transaction required more than 'max_binlog_cache_size' (다중 문장 트랜잭션이 'max_binlog_cache_size'보다 많은 공간을 요구함)
- 1785Statement violates GTID consistency
- 3024Query execution was interrupted, maximum statement execution time exceeded (쿼리 실행이 중단됨. 최대 문장 실행 시간 초과)