부자 되기 위한 블로그, 머니킹

안녕하세요. 오늘도 열심히 프로젝트를 개발중에 있습니다. 프로젝트 개발 중 최종적인 db로 aws ec2에 mariadb를 설치하여 이용하기로 마음먹었습니다. 일단 ec2에는 amazon linux를 설치하였고 mariadb를 설치하는데 당연하게도 최신 버전이 설치합니다. 하지만 mariadb 최신 버전에는 한가지 문제가 있더군요. 바로 인코딩 문제입니다. 이번 포스팅에서는 인코딩 오류를 해결하는 방법에 대해 포스팅하려고 합니다.

 

mariadb 최신 버전 인코딩 오류

먼저 이 글에 작성된 mariadb 버전은 5.5? 이상 버전인것으로 기억합니다. 포스팅 시점이 해결한 시점 2일뒤라서 두서없이 해결 방법을 알려드리겠습니다.

 

/etc/my.cnf 를 vim 으로 열고 해당과 같이 작성되있으면 됩니다. 아마 client 부분부터 mysqld까지 수동으로 입력해주었던 것 같습니다.

 

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

그리고 sudo systemctl restart mariadb.service를 입력하여 재시작해주어야 합니다. 현재 실행 여부는 systemctl status mariadb.service를 입력하여 확인할 수 있습니다