MariaDB Encoding 설정

데이터를 한글로 저장하려는 순간 다음 에러가 발생하였다. 영어로 저장할 때는 저장이 되다가 발생한 문제였기에 DB나 SpringBoot에서 CharacterSet에 대한 설정을 안해줘서 발생한 문제로 보인다.

java.sql.SQLSyntaxErrorException: (conn=3031) Incorrect string value: '\xEC\x95\x84\xEC\x95\x84...' for column 'content' at row 1

맨 아래에 해당 텍스트를 추가한다.
1.vi /etc/my.cnf

[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

2.sudo systemctl restart mariadb

하지만 해당 설정은 기존에 생성된 DB에는 적용되지 않아 새로 생성을 해주었다.

출처:
https://yonguri.tistory.com/113
https://velog.io/@kms9887/Ncloud-배포하기1-mysql-설치

'Linux > DB' 카테고리의 다른 글

MySQL 데이터베이스 백업 및 복원  (0) 2024.06.21