Mysqldump backup database Chinese garbled characters and MySQL import database Chinese garbled solution 1
Mysqldump backup database Chinese garbled solution 1
If the character set on the MySQL server is Latin1, Chinese characters from mysqldump are garbled! A simple method is to add the default character set options, such:
Mysqldump-H 127.0.0.1-P 3307-u username -- default-character-set = GBK-P databasename> dumpfile.txt
-H host
-P port. This option must be used separately, but cannot be consecutively written after the host address.
-U User Name
-- When the default-character-set knows that the data content is Chinese, it can be specified as GBK, so that even if the database itself sets the character set to the Chinese language of the file Latin1, it can be normal!
-P Password
Databasename Database Name
> The following is the path of the output file.
Garbled characters occur when MySQL command line imports data
Sometimes, because the SQL data volume is large and you need to import data under the command line, garbled characters may occur in the imported data. Execute the following command to solve the problem:
1. Use Database;
2. Set Character Set utf8; (eg: GBK)
3. Source example. SQL (SQL file path)