4
4

2 回答 2

8

Table/column character sets need to be set to a version that supports multibyte like UTF8.

You may be able to tell the current table character set by doing a

mysql> SHOW CREATE TABLE tbl_Name;

It may not show you anything in which case it's using the default defined in you my.cnf

To change a character set on a table run:

mysql> ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

I don't recommend this if you have a lot of data or can't remove the data and start fresh. The transition needs to remove the bad data first.

I read through this post and it seems in depth and from what I can remember of my own battles with this very accurate. http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html

Also, to create new tables as UTF-8 append CHARACTER SET utf8 COLLATE utf8_general_ci to the end of your CREATE TABLE statements

于 2010-05-23T03:53:21.613 回答
2

Verify that you have specified "charset=utf8" in your connection string. For example

connectionString="Server=myServerHost;charset=UTF8;Database=myDatabase;Uid=root;Pwd=password;"

As noted in Character Sets and Collations in General MySQL can do:

  • Store strings using a variety of character sets
  • Compare strings using a variety of collations
  • Mix strings with different character sets or collations in the same server, the same database, or even the same table
  • Allow specification of character set and collation at any level
于 2010-05-23T03:53:34.053 回答