2023년 7월 19일 수요일

mariadb ER_CANT_AGGREGATE_2COLLATIONS 에러발생

테이블 charset 이 utf8mb4 일때 클라이언트 charset 을 따로 설정하지 않으면 이모지 사용할때 아래와 같은 오류가 난다.

code: 'ER_CANT_AGGREGATE_2COLLATIONS',

0|api.dlwl |   errno: 1267,

0|api.dlwl |   sqlMessage: "Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb3_general_ci,COERCIBLE) for operation '='",

0|api.dlwl |   sqlState: 'HY000',

0|api.dlwl |   index: 0,



나의 경우는 nodejs mysql 모듈에서 난 오류인데, 아래와 같이 수정하면 됨. 서버와 클라이언트 간에 charset 맞추는거 까먹지말자..
const config = {
  ...
charset:'utf8mb4',
};

connection = mysql.createConnection(config);