[MySQL] Character SET 변경

MySQL 2014. 6. 21. 00:57

mysql 캐릭터 셋 변경 방법

디비 내에서 직접 변경

mysql>show variables like '%char%';

+--------------------------+----------------------------+
| Variable_name                  | Value                                 |
+--------------------------+----------------------------+
| character_set_client          | latin1                                  |
| character_set_connection  | latin1                                  |
| character_set_database    | latin1                                   |
| character_set_filesystem   | binary                                  |
| character_set_results       | latin1                                   |
| character_set_server        | latin1                                   |
| character_set_system       | utf8                                     |
| character_sets_dir            | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
 
msyql> set character_set_client = euckr;
msyql> set character_set_connection = euckr;
msyql> set character_set_database = euckr;
msyql> set character_set_filesystem = euckr;
msyql> set character_set_results = euckr;
msyql> set character_set_server = euckr;
 
mysql>show variables like '%char%';
+--------------------------+------------------------------------+
| Variable_name                  | Value                                             |
+--------------------------+------------------------------------+
| character_set_client          | euckr                                              |
| character_set_connection  | euckr                                              |
| character_set_database    | euckr                                               |
| character_set_filesystem   | euckr                                               |
| character_set_results       | euckr                                               |
| character_set_server        | euckr                                               |
| character_set_system       | utf8                                                  |
| character_sets_dir            | /usr/share/mysql/charsets/             |
+--------------------------+------------------------------------+

 

my.cnf 파일을 통한 캐릭터 셋 변경 

 

# cat /etc/my.cnf

[mysql]

 

default-character-set = utf8


[mysqld]

character-set-client-handshake=FALSE

init_connect="SET collation_connection = utf8_general_ci"

init_connect="SET NAMES utf8"

default-character-set = utf8

character-set-server = utf8

collation-server = utf8_general_ci


datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0


[client]

default-character-set = utf8


[mysqldump]

default-character-set = utf8


[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid 

MySQL 재시작 

# service mysqld restart 
Stopping MySQL: [ OK ] 
Starting MySQL: [ OK ] 

status를 통해 서버와 mysql의 인코딩이 통일 되었는지 확인

mysql> status
--------------
mysql  Ver 14.14 Distrib 5.1.61, for redhat-linux-gnu (x86_64) using readline 5.1

Connection id:          8
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.1.61 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 27 min 16 sec

Threads: 1  Questions: 52  Slow queries: 0  Opens: 23  Flush tables: 1  Open tables: 11  Queries per second avg: 0.31
--------------

mysql> show variables like 'c%' ;

Posted by 24X365

댓글을 달아 주세요