캐릭터셋(CharSet) 변경

리눅스/MySQL|2015. 1. 16. 10:43
반응형

캐릭터 셋 utf-8 에서 euckr 로 바꾸는 예제

1) 확인
mysql> 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/local/mysql/share/mysql/charsets/ |
| collation_connection     | utf8_general_ci                        |  <- 변경
| collation_database       | utf8_general_ci                        |  <- 변경
| collation_server         | utf8_general_ci                        |  <- 변경
| completion_type          | 0                                      |
| concurrent_insert        | 1                                      |
| connect_timeout          | 5                                      |
+--------------------------+----------------------------------------+


2) 변경 (일시적인 방법. MySQL을 재시작 하면 원래 값으로 돌아간다.)
msyql> set character_set_client = euckr;
msyql> set character_set_connection = euckr;
msyql> set character_set_database = euckr;
msyql> set character_set_results = euckr;
msyql> set character_set_server = euckr;
mysql> set collation_connection = euckr_korean_ci;
mysql> set collation_database = euckr_korean_ci;
mysql> set collation_server = euckr_korean_ci;

3) 확인
mysql> show variables like 'c%';
+--------------------------+----------------------------------------+
| Variable_name            | Value                                  |
+--------------------------+----------------------------------------+
| character_set_client     | euckr                                  |
| character_set_connection | euckr                                  |
| character_set_database   | euckr                                  |
| character_set_filesystem | binary                                 |
| character_set_results    | euckr                                  |
| character_set_server     | euckr                                  |
| character_set_system     | utf8                                   |
| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |
| collation_connection     | euckr_korean_ci                        |
| collation_database       | euckr_korean_ci                        |
| collation_server         | euckr_korean_ci                        |
| completion_type          | 0                                      |
| concurrent_insert        | 1                                      |
| connect_timeout          | 5                                      |
+--------------------------+----------------------------------------+


4) 변경2 (온전한 변경 방법)

/etc/my.cnf 파일을 변경 해줍니다.

[client] 
default-character-set=euckr 

[mysqld] 
default-character-set=euckr        // 이 옵션은 5.5 버전에서 적용되지 않으므로 빼시기 바랍니다.
init_connect=SET collation_connection=euckr_korean_ci 
init_connect=SET NAMES euckr 
character-set-server=euckr 
collation-server=euckr_korean_ci 

[mysqldump] 
default-character-set=euckr 

[mysql] 
default-character-set=euckr 

추가 및 변경 후, MySQL 을 재시작 해주어야 적용된다.


5) 아파치 캐릭터셋 확인

/usr/local/apache/conf/httpd.conf 파일을 변경(내용 추가)해줍니다.

AddDefaultCharset euckr


※ 참고1 : UTF-8사용 : AddDefaultCharset UTF-8
    참고2 : Apache 버젼 2.2.6 이상의 경우, /usr/local/apache/conf/extra/httpd-languages.conf 를 수정.

추가 및 변경 후, Apache 를 재시작 해주어야 적용된다.

 

 

[참고]

5.0 버전에서 확인한 결과 my.cnf에서 아래 세군데만 바꿔도 변경(또는 등록) 가능했습니다.

[client]
default-character-set=euckr

[mysqld]
default-character-set=euckr

[mysql]
default-character-set=euckr



반응형

댓글()