MySQLã®æåã³ã¼ããUTF8ã«å¤æ´ããæé
ï¼ Fedora8ãMySQL5.0.45ãã©ã®è¨å®ãå®éä½ã«ä½¿ããã¦ããã®ãã詳ããã¯èª¿ã¹ã¦ãªããã©ãå ¨é¨UTF8ã«ãã¦ããã°åé¡ãªãã ããã¨ããé©å½ãªæ¨æ¸¬ã«åºã¥ãã¦å¤æ´ãã¦ããæé ãã¡ã¢ãæååãã«ã¯æ©ã¿ãããªãã
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/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) mysql> set names utf8; Query OK, 0 rows affected (0.00 sec) mysql> show variables like "char%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
è¨å®ãã¡ã¤ã«ã«âã追è¨ãã¦åèµ·åããã¾ãã
# cd /etc/ # vi my.cnf [mysqld] default-character-set=utf8 # /etc/init.d/mysqld restart MySQL ãåæ¢ä¸: [ OK ] MySQL ãèµ·åä¸: [ OK ]
mysql> show variables like "char%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) mysql> show variables like "char%"; +--------------------------+----------------------------+ | 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/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
æ¢ã«ä½ææ¸ã¿ã®DBã®æåã³ã¼ããå¤æ´ããå ´åã¯
ALTER DATABASEãã
ALTER TABLEãã
ALTER TABLE ALTER COLUMNãã
ãªã©ã§DEFAULT CHARACTER SETãå¤æ´ã