Solution to garbled characters when importing data from MYSQL database

Source: Internet
Author: User

First, when creating a database, be sure to generate the same encoding format of the original database. If the database has been generated, use phpmyadmin and other tools to organize it again to prevent garbled characters caused by inconsistent database encoding and table encoding.

Method 1: add the parameter-default-character-set = utf8 to solve the Garbled text problem.
Mysql-u root-p password <path_to_import_file-default-character-set = utf8

Method 2: solve the problem by importing garbled characters in the command line

1. use database_name;
2. set names utf8; (or other required encoding)
3. source example. SQL (SQL file storage path)

Method 3: directly paste the code in the SQL File
1. Open the SQLyog client software;
2. Locate the SQL editor and use NotePad to open the exported SQL file;
3. Copy all SQL statements in the file to the SQL editor and execute the SQL code;

Method 4: use notepad or other text tools to change the encoding format of the SQL file (if method 3 fails, try Method 4)

1. Use notepad (or UE) to open the exported SQL file;
2. Save this file. Open the "Save as" dialog box and select the UNICODE encoding format in the dialog box;
3. Save the file, press CTRL + A, and select all;
4. Copy the SQL statement to the "SQL encoder" in SQLyog and execute the SQL statement again;
5. Refresh the data table once after the execution is complete. Check the data table in Chinese and eliminate the garbled characters;

Related Article

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.