With the MySQL tool mysqldump backup database, if the MySQL server's character set is Latin1, the second world collation release mysqldump out of the Chinese are garbled! An easy way to do this is to add the default character set options when writing a backup statement, such as:
| The code is as follows |
Copy Code |
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, not continuously behind the host address
-U user Name
--default-character-set know that the data content is Chinese can be specified as GBK, so even if the database itself set the character set for the latin1 out of the file in Chinese can be normal!
-p password
DatabaseName Database name
> Following is the path to the output file
Garbled when importing data from MySQL command line
Sometimes because of the large amount of SQL data, you need to import data under the command line, you can encounter the data in the lead garbled, execute the following command can be resolved:
| The code is as follows |
Copy Code |
1. Use database; 2.set character set UTF8; (EG:GBK) 3.source example.sql (SQL file path) |
Summary Import Export Chinese garbled
Summarize
SQL appears garbled most likely is the database's global encoding and a database encoding inconsistent. You can add code at the time of export and can be modified to UTF8 or GBK.
| code is as follows |
copy code |
| mysqldump– U username--default-character-set=utf8-p database name > file path filename. sql |