Chinese garbled solution for mysqldump backup Database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.