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;