Wednesday, October 7, 2009

Mysql database migration special character issue

While migrating data from one database to another in mysql, I hit with a small issue.


it’s was changing to itâs in the database and get rendered as it’s on the website


Solution

For a varchar(255) column named “column_name” in a table named “example_table”:

ALTER TABLE example_table MODIFY column_name BINARY(255);
ALTER TABLE example_table MODIFY column_name VARCHAR(255) CHARACTER SET utf8;

For a text column named “text_column_name” in a table named “example_table”:

ALTER TABLE example_table MODIFY text_column_name BLOB;
ALTER TABLE example_table MODIFY text_column_name TEXT CHARACTER SET utf8;

reference

http://www.orthogonalthought.com/blog/index.php/2007/05/mysql-database-migration-and-special-characters/

No comments:

Post a Comment