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.
You should also read:
- MySQL: Change Default Character Set or Default Collation in phpMyAdmin
- Backup and recover a MySQL database under command line
- MySQL: LOAD DATA LOCAL INFILE only imports 1 or 2 rows?
- PHP String Length function to Get Length of Strings in PHP
- MySQL: How to backup ALL databases as root with mysqldump at once?


Facebook
Twitter
Google Plus