Friday, January 27, 2012

MySQL character-set problem: Convert an entire MySQL database character-set and collation to UTF-8?

I got the error below after add/remove some column in a table and do 'join'

Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='

I solve this by change char set of table as follows:

ALTER TABLE `db_name`.`tbl_name` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

the better way is change db char set then change table's as follows:

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE tablename CHARACTER SET utf8 COLLATE utf8_general_ci;

References:

http://stackoverflow.com/questions/6115612/how-to-convert-an-entire-mysql-database-characterset-and-collation-to-utf-8

No comments:

Post a Comment