mysql command line character set option for importing SQL files encoded in UTF8
For languages other than English, especially those in Asia such as Chinese, each character takes 2 bytes in storage and needs to be encoded in UTF8 or other encoding specifically designed for it.
Normally, the command line mysql database importing command has no problem with English database SQL files that are encoded in ANSI or ISO-8859-x, when the SQL file is encoded in UTF8 and contains foreign language characters, however, the imported data will end up in a mess in the database.
To work around this problem, you have to specify the default character set in the mysql command line:
mysql -h localhost -u user1 -p --default_character_set utf8 somedb < backup.sql
And you should have no problem.
0 comments:
Post a Comment