开发者

Mysql -change DB,tables to utf8

In /etc/my.cnf the following has been added


character-set-server=utf8
collation-server=utf8_general_ci

But for the database and tables created 开发者_开发问答before adding the above how to convert the database and tables to utf8 with collation settings


Well, the database character set and table character set are just defaults (they don't affect anything directly). You'd need to modify each column to the proper charset. PHPMyAdmin will do this for you (just edit the column, then change the character set). If you want to do raw SQL, you'll need to know the column definition (SHOW CREATE TABLE foo will show you the definition). Then, you can use ALTER TABLE to change the definition.

To change the default charset for a table:

ALTER TABLE `tablename` DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';

To change the charset of a column with the definition `foo VARCHAR(128) CHARACTER SET 'foo' COLLATE 'foo'``:

ALTER TABLE `tablename` MODIFY 
    `foo` VARCHAR(128) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';


https://serverfault.com/questions/65043/alter-charset-and-collation-in-all-columns-in-all-tables-in-mysql

And:

http://www.mysqlperformanceblog.com/2009/03/17/converting-character-sets/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜