[mariadb] utf-8 설정하기

2019. 7. 9. 13:47IT-개발/DB

반응형

기본 설정 상태보기

 

MariaDB [(none)]> show variables like 'c%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
| collation_connection | utf8_general_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
| completion_type | NO_CHAIN |
| concurrent_insert | AUTO |
| connect_timeout | 10 |
+--------------------------+----------------------------+
14 rows in set (0.01 sec)

 

 

디폴트 캐릭터셋을 latin1에서 utf-8으로 변경하기 위해, 아래 3개의 파일에 캐릭터셋 설정을 추가한다.

 

• vi /etc/my.cnf.d/client.cnf

[client]
default-character-set=utf8


• vi /etc/my.cnf.d/mysql-clients.cnf

[mysql]
default-character-set=utf8

[mysqldump]
default-character-set=utf8


• vi /etc/my.cnf.d/server.cnf

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

 

(DB 재실행)

@ systemctl restart mariadb

 

(이미 생성한 database가 있다면 삭제 / 생성 및 data 추가)

 

 

MariaDB [(none)]> show variables like 'c%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
| collation_connection | utf8_general_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
| completion_type | NO_CHAIN |
| concurrent_insert | AUTO |
| connect_timeout | 10 |
+--------------------------+----------------------------+
14 rows in set (0.00 sec)

 

이렇게 나올거 같다.