MySQL command line restore phpMyAdmin exported SQL files containing Chinese

Source: Internet
Author: User

Recently got a dozens of m of MySQL script file, ready to revert to the database.

Used to use the Mysql-front for a short time MySQL, first use it to try, the results hang off.

Well, first create an empty database with Mysql-front, and then import it using the MySQL command line.

1 Use Mysql-front to create an empty database

Because look at the object in the script have default CHARSET=GBK comment= ... directive, so character set selection GBK

2 start the MySQL command line, enter the password

3 using the new database B

Enter command: use B;

4 Change the file read character set to UTF8, this step is critical

At the beginning, when you see the default CHARSET=GBK comment= ... and think you want to set it to GBK, you use the following instructions:

Set names GBK;

But when you import, it's all an error and you can't recognize Chinese.

Later realized that it should be set to the character set of the SQL file itself, what is the character set of the SQL file itself?

My method is to open the file with the Vs.net IDE and save As, select "Encoding Save"

Thus the character set is utf-8;

So

Input command: set names UTF8; Note that it is not set names Utf-8;

5) Import File

Input command: source file path;

Soon, the file was successfully imported into the database, which was highly efficient.

Look at the Mysql-front, the data normal import, done!

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.