You can use the ALTER TABLE/DATABASE SQL statements to convert your data.
To set the default character set for a database, use the following statement.
ALTER DATABASE <database_name> CHARACTER SET utf8;
This does not affect any existing tables, but any future tables created in this database will use utf8 by default.
For each table you want to convert to utf8, use the following statement.
ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8;
This will automatically convert all text columns to utf8.
"The CONVERT TO operation converts column values between the character sets. This is not what you want if you have a column in one character set (like latin1) but the stored values actually use some other, incompatible character set (like utf8). In this case, you have to do the following for each such column:
ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;
The reason this works is that there is no conversion when you convert to or from BLOB columns."
No comments:
Post a Comment