[MySQL] euckr -> utf8 ·Î ¾ð¾î º¯È¯ ÆÁ
euckr À» utf8 ·Î º¯°æ ½Ã ÇѱÛÀº ±úÁú¼ö ¹Û¿¡ ¾ø´Ù´Ï ´çÄ¡µµ ¾Ê½À´Ï´Ù.
euckrÀ» utf8·Î º¯°æÇÏ´Â ÀÛ¾÷À» ¸¹ÀÌ Çß¾ú´Âµ¥, ¾Æ¹«·± ¹®Á¦ ¾øÀÌ utf8·Î º¯°æÇß¾ú½À´Ï´Ù.
ÁÖ·Î Á¦·Îº¸µå ÀÌÀü ¹öÀüÀ» utf8·Î º¯°æÇϱâ À§Çؼ ¸¹ÀÌ Çß¾úÁÒ.
¾Æ·¡ ¸»¾¸µå¸®´Â »çÇ×Àº euckrÀ» utf8·Î º¯°æÇϱâ À§ÇÑ Á¦ ³ª¸§´ë·ÎÀÇ ÆÁÀÔ´Ï´Ù.
(utf8·Î º¯°æÇÏ´Â ¹æ¹ýÀº ¾ÆÁÖ ¸¹±â ¶§¹®¿¡ ¾Æ·¡ ¹æ¹ýÀ» µû¸£Áö ¾Ê¾Æµµ º¯È¯ °¡´ÉÇÏ´Ù´Â Á¡À» ¹Ì¸® ¸»¾¸µå¸³´Ï´Ù.)
1.
sql ÆÄÀÏÀ» »ý¼ºÇÒ ¶§ 4.1 ¹öÀüºÎÅÍ´Â default-character-setÀ» ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é utf8·Î ¼³Á¤µË´Ï´Ù. mysqldump¸¦ ÇÒ ¶§ ¹Ýµå½Ã Å×À̺íÀÇ ¹®Àڼ°ú µ¿ÀÏÇÑ default-character-set(Áï euckr)À¸·Î ÁöÁ¤ÇØÁà¾ß ÁÁ½À´Ï´Ù.
mysqldump --default-character-set=euckr a > a.sql
2.
mysqldump·Î ¸¸µç sql ÆÄÀÏÀ» iconv¸¦ ÀÌ¿ëÇØ utf8·Î ¹Ì¸® º¯È¯ÇÏ´Â°Ô ÁÁ½À´Ï´Ù.
eucKR ´ë½Å¿¡ CP949¸¦ ¾²´Â°Ô ´õ ÁÁÀ» °æ¿ì°¡ ¸¹¾Ò½À´Ï´Ù.
iconv -f CP949 -t UTF-8
3.
sql ÆÄÀÏ¿¡¼ character set °ü·Ã ¼³Á¤ÀÌ ÀÖ´Ù¸é Áö¿ì´Â°Ô ÀÛ¾÷ÀÌ ÆíÇÕ´Ï´Ù.
CREATE TABLE `zetyx_admin_table` ( ... ) ENGINE=MyISAM DEFAULT CHARSET=euckr;
À§ ºÎºÐÀ» ¾Æ·¡Ã³·³ ¹Ù²Ù¸é µË´Ï´Ù.
CREATE TABLE `zetyx_admin_table` ( ... ) ENGINE=MyISAM;
sql ÆÄÀÏ Å©±â°¡ ³Ê¹« Ä¿¼ ÆíÁýÇϱⰡ Èûµé´Ù¸é mysqldump¸¦ ÇÒ ¶§ ½ºÅ°¸¶¿Í µ¥ÀÌÅ͸¦ ºÐ¸®Çؼ ¸¸µé¸é ¿ë·® ÀÛÀº ½ºÅ°¸¶ ÆÄÀϸ¸ ÆíÁýÇÏ¸é µÇ´Ï ÆíÇÕ´Ï´Ù.
mysqldump --no-data --default-character-set=euckr a > a_schema.sql mysqldump --no-create-info --default-character-set=euckr a > a_data.sql
Å×ÀÌºí ½ºÅ°¸¶¸¸ ÀúÀåÇϱâ À§Çؼ´Â --no-data ¿É¼ÇÀ» ÁÖ¸é µË´Ï´Ù. ¹Ý´ë·Î µ¥ÀÌÅÍ insert¹®¸¸ ÀúÀåÇϱâ À§Çؼ´Â --no-create-info ¿É¼ÇÀ» ÁÖ¸é µË´Ï´Ù.
4.
mysqldump¸¦ ÇÒ ¶§ ¿É¼ÇÀ» ¾î¶»°Ô Áá´À³Ä¿¡ µû¶ó sql ÆÄÀÏ ³»¿¡ set names euckrÀ̶ó´Â ºÎºÐÀÌ µé¾î°¡ ÀÖÀ» ¼ö ÀÖ½À´Ï´Ù.
µé¾î°¡ ÀÖ´Ù¸é ÀÌ ºÎºÐÀ» Áö¿ì°í
sql ÆÄÀÏ ¸Ç ¾Õ¿¡ ¾Æ·¡ ºÎºÐÀ» Ãß°¡ÇØÁÖ´Â °ÍÀÌ ÁÁ½À´Ï´Ù.
set names utf8;
5.
¿Å°Ü°¥ ¼¹ö ¼³Á¤¿¡ µû¶ó ºÒÇÊ¿äÇÒ ¼ö ÀÖ½À´Ï´Ù¸¸, µ¥ÀÌÅͺ£À̽º¸¦ ¸¸µé ¶§ ut8À» ¸í½ÃÇØ ÁÖ´Â °ÍÀÌ ÁÁ½À´Ï´Ù.
CREATE DATABASE db_name DEFAULT CHARACTER SET utf8
µ¥ÀÌÅͺ£À̽º¸¦ ¸¸µé¾ú´Ù¸é ´ÙÀ½°ú °°ÀÌ Á¦´ë·Î utf8·Î ¼³Á¤µÇ¾ú´ÂÁö È®ÀÎÇغ¸½Ê½Ã¿À.
mysql> USE db_name; Database changed mysql> SHOW VARIABLES LIKE '%DATABASE'; +------------------------+-----------------+ | Variable_name | Value | +------------------------+-----------------+ | character_set_database | utf8 | | collation_database | utf8_general_ci | | skip_show_database | OFF | +------------------------+-----------------+
-- academicÀº Á¦ °íµîÇб³ ¶§ µ¿¾Æ¸® À̸§ÀÔ´Ï´Ù. academic, ¾ÆÁÖ °¡²ûÀº Àúµµ ÀÌ·¨À¸¸é ÁÁ°Ú½À´Ï´Ù
|