선 밖에 선 자유인

mysql 한글 깨짐 해결 본문

IT/System & Network

mysql 한글 깨짐 해결

Hotman 2014. 2. 26. 14:22

mysql 한글 깨질 때


mysql> status

--------------

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


...

Connection:             Localhost via UNIX socket

Server characterset:    latin1

Db     characterset:    latin1

Client characterset:    latin1

Conn.  characterset:    latin1

UNIX socket:            /var/lib/mysql/mysql.sock

Uptime:                 14 days 4 hours 31 min 13 sec


Threads: 1  Questions: 82305  Slow queries: 0  Opens: 713  Flush tables: 1  Open tables: 27  Queries per second avg: 0.67

--------------


- mysql charset 변경

/etc/my.cnf 에 아래의 문구 추가

[mysqld]

default-character-set = utf8

[client]

default_character_set=utf8


mysql 재시작 후 확인


mysql> status

--------------

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


...

Server characterset:    utf8

Db     characterset:    latin1

Client characterset:    utf8

Conn.  characterset:    utf8

UNIX socket:            /var/lib/mysql/mysql.sock

Uptime:                 1 min 31 sec


Threads: 1  Questions: 50  Slow queries: 0  Opens: 30  Flush tables: 1  Open tables: 23  Queries per second avg: 0.549

--------------


한글 출력 됨


만약 해당 DB의 charset 까지 변경하고 싶으면 


mysql> show create database <db_name>;

mysql> alter database <db_name> character set = 'utf8'


mysql> status

--------------

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


...

Server characterset:    utf8

Db     characterset:    utf8

Client characterset:    utf8

Conn.  characterset:    utf8



Comments