Home  >  Article  >  Database  >  How to solve the problem of Chinese garbled characters in mysql csv

How to solve the problem of Chinese garbled characters in mysql csv

藏色散人
藏色散人Original
2023-02-13 09:55:563632browse

The solution to the Chinese garbled problem of mysql csv is to select the encoding method of "10008 (MAC-Simplified Chinese GB 2312)" or the encoding of "10008 (MAC-Simplified Chinese GB 2312)" when importing the csv file method.

How to solve the problem of Chinese garbled characters in mysql csv

The operating environment of this tutorial: Windows 10 system, mysql version 5.7, Dell G3 computer.

How to solve the problem of Chinese garbled characters in mysql csv?

When MySQL imports CSV files, the problem of Chinese garbled characters appears and its solution

Problems

When using the Navicat tool to import a .csv file containing Chinese fields into the local database, the garbled code as shown below appears. .

After my verification, it is not a database fieldDesignproblem. So I guess it has something to do with the encoding when importing. The following 65001utf-8 I thought there was no problem at first, but the problem appears here!
How to solve the problem of Chinese garbled characters in mysql csv

Solution

Select the encoding method of 10008 (MAC-Simplified Chinese GB 2312) when importing!

Encoding is particularly important. You must choose 10008 (MAC-Simplified Chinese GB 2312). You cannot use the default utf-8, because CSV files containing Chinese are generally Use 10008 encoding instead of utf8.

Successfully solved!
How to solve the problem of Chinese garbled characters in mysql csv

Wrong way:
How to solve the problem of Chinese garbled characters in mysql csv

If the encoding is incorrect, garbled characters will appear! ! !

Expansion issues

Test if you use text to import and use the utf-8 encoding method to import, will there be garbled characters? , and it turns out that garbled characters will also appear when importing!
How to solve the problem of Chinese garbled characters in mysql csv

Select the encoding method of 10008 (MAC-Simplified Chinese GB 2312) when importing! This problem can also be solved.
How to solve the problem of Chinese garbled characters in mysql csv

Summary: The imported data is garbled, which is most likely a problem with the encoding method.

Recommended learning: "MySQL Video Tutorial"

The above is the detailed content of How to solve the problem of Chinese garbled characters in mysql csv. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn