MySQL data import restore time garbled problem

Source: Internet
Author: User

Workaround:

The first step: to restore the database and tables are UTF8 format (recommended UTF8, of course GBK or gb2312 also line)

The code is as follows:

CREATE DATABASE ' Shegongku ' DEFAULT CHARACTER SET UTF8
CREATE TABLE ' Members ' (
' UID ' mediumint (8) unsigned not NULL default ' 0 ',
' username ' varchar not NULL default ',
' Password ' varchar not NULL default ',
' Salt ' varchar default NULL,
' Email ' varchar not NULL default '
) Engine=myisam DEFAULT Charset=utf8;

The second part, the conversion of the Code of the SQL file into UTF8 format, can be notepad2, can also be converted with ultraeditor, and then in the first row of the SQL file add a row of set names UTF8 save.


Part III, import. Generally will not appear garbled, then if you are in the terminal cmd query again found or garbled words, this is not a database problem, but the display of the problem, in the terminal input set names GBK, so that Chinese will show normal

Continue the document


Method one: By adding parameter –default-character-set = UTF8 solve garbled problem

Mysql-u root-p Password < Path_to_import_file–default-character-set = UTF8

Method Two: Import garbled solution on the command line

1. Use database_name;
2. Set names UTF8; (or other required encoding)
3. Source example.sql (SQL file storage path)

Method Three: Directly paste the code in the SQL file

1. Open SQLyog client software;
2. Navigate to the SQL Editor, and then use Notepad to open the SQL file just exported;
3. Copy all SQL statements from the file into the SQL editor and execute the SQL code;

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.