Mysql command line imports SQL data and solves Chinese garbled characters when accessing the website

Source: Internet
Author: User
Method 1: Solve the Problem of mysql garbled by adding the parameter-default-character-setutf8 mysql-uroot-ppasswordpath_to_import_file-default-character-setutf8 Method 2: mysql in the command line to import garbled 1. usedatabase_name; 2. setnamesutf8; (or other required encoding)

Method 1: add the parameter-default-character-set = utf8 to solve the mysql garbled problem mysql-u root-p password path_to_import_file-default-character-set = utf8 Method 2: mysql can solve the problem by importing garbled characters in the command line. use database_name; 2. set names utf8; (or other required Encoding

Method 1:Mysql garbled by adding the parameter-default-character-set = utf8
Mysql-u root-p password <path_to_import_file-default-character-set = utf8

Method 2:Mysql command line import garbled

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 mysql garbled characters;

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.