Language
한국어

[mysql] 인코딩 변경

2013.09.05 13:08

suritam9 조회 수:3011

phpmyadmin에서도 수정 가능하도록 

php 에서


    mysql_query("set session character_set_connection=utf8;");

    mysql_query("set session character_set_results=utf8;");

    mysql_query("set session character_set_client=utf8;");


를 적용하고, 서버에서도 완전하게 

mysql -u root -p


msyql> set character_set_client = utf8;

msyql> set character_set_connection = utf8;

msyql> set character_set_database = utf8;

msyql> set character_set_results = utf8;

msyql> set character_set_server = utf8;

mysql> set collation_connection = utf8_general_ci;

mysql> set collation_database = utf8_general_ci;

mysql> set collation_server = utf8_general_ci;


적용 시킨다.

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/share/mysql/charsets/ |

| collation_connection     | utf8_general_ci            |

| collation_database       | utf8_general_ci            |

| collation_server         | utf8_general_ci            |

| completion_type          | NO_CHAIN                   |

| concurrent_insert        | AUTO                       |

| connect_timeout          | 10                         |

+--------------------------+----------------------------+

14 rows in set (0.00 sec)



/etc/mysql/my.cnf 에서
[client] 
default-character-set=utf8
 
[mysqld] 
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
 
[mysql] 
default-character-set=utf8

이를 추가해 재시작시 적용되도록 한다. 재시작을 안 해봐서 모르겠지만, 되겠지.