テーブルのエンコーディングを調べるのは
1 |
mysql> show create table TABLE_NAME \G |
エンコーディングの変更は
1 |
mysql> alter table TABLE_NAME convert to CHARSET XXXX; |
例えば、エンコーディングが「latin1」となっているhogeテーブルを「UTF-8」にすると
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
mysql> show create table hoge \G *************************** 1. row *************************** Table: hoge Create Table: CREATE TABLE `hoge` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `mail` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql> alter table hoge convert to CHARSET utf8 COLLATE utf8_unicode_ci; Query OK, 5 rows affected (0.01 sec) Records: 5 Duplicates: 0 Warnings: 0 mysql> show create table hoge \G *************************** 1. row *************************** Table: hoge Create Table: CREATE TABLE `hoge` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `mail` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 1 row in set (0.00 sec) |