| Articles | CREATE TABLE ' articles ' (' id ' int (one) not null auto_increment, ' content ' longtext not null, PRIMARY KEY (' id ')) ENGINE =innodb auto_increment=16 DEFAULT charset=latin1 |mysql> select * from articles;+----+---------+| ID | Content |+----+---------+| 11 | Ha | | 12 | Xi | | 13 | Ai | | 14 | Ho | | 15 |?? |+----+---------+5 rows in Set (0.01 sec) mysql> ALTER TABLE articles default character set UTF8; Query OK, 5 rows affected (0.38 sec) records:5 duplicates:0 warnings:0mysql> SELECT * from articles;+----+--------- +| ID | Content |+----+---------+| 11 | Ha | | 12 | Xi | | 13 | Ai | | 14 | Ho | | 15 |?? |+----+---------+5 rows in Set (0.01 sec) | Articles | CREATE TABLE ' articles ' (' id ' int (one) not null auto_increment, ' content ' Longtext CHARACTER SET latin1 not NULL, PRIMA RY KEY (' id ')) engine=innodb auto_increment=16 DEFAULT Charset=utf8 |mysql> insert into articles (Id,content) VALUES (1 6, ' modify character set '); Query OK, 1 Row affected, 1 warning (0.08 sec) mysql> Select * from articles;+----+---------+| ID | Content |+----+---------+| 11 | Ha | | 12 | Xi | | 13 | Ai | | 14 | Ho | | 15 |?? || ????? |+----+---------+6 rows in Set (0.00 sec) # But the problem is still, as if only deleted, re-import data will take effect! Understand when the table is built, the field definition is: ' content ' longtext CHARACTER SET latin1 not null,mysql> insert into articles (Id,content) VALUES (1, ' Forest '), (2, ' Chen '); Query OK, 2 rows affected, 2 warnings (0.10 sec) records:2 duplicates:0 warnings:2mysql> select * from articles;+-- --+---------+| ID | Content |+----+---------+| 1 |? || 2 |? |+----+---------+2 rows in Set (0.00 sec)
mysql> drop table articles; Query OK, 0 rows affected (0.11 sec) mysql> CREATE TABLE ' articles ' ( ' id ' int (one) ' Not NULL auto_increment, ' con Tent ' longtext not NULL, PRIMARY KEY (' id ')) engine=innodb auto_increment=15 DEFAULT Charset=utf8; Query OK, 0 rows affected (0.08 sec) mysql> insert into articles (Id,content) VALUES (1, ' Forest '), (2, ' Chen '); Query OK, 2 rows affected (0.08 sec) records:2 duplicates:0 warnings:0mysql> select * from articles;+----+--- ------+| ID | Content |+----+---------+| 1 | Forest | | 2 | Chen |+----+---------+2 rows in Set (0.00 sec)
Higher priority for setting character sets when defining fields