Mysql database uses SQLyog to import Chinese csv files with garbled characters

Source: Internet
Author: User
[Memo] My requirement is to unify into a gbk type. Garbled characters occur when SQLyog is used to import data from csv files containing Chinese characters to the MySQL database. Symptoms: 1. directly import the CSV file. The data is imported successfully, but garbled characters are displayed in sqlyog. 2. use the insert statement to import and test sqlyog. garbled characters are displayed after data is saved. 3. run cmd

[Memo] My requirement is to unify into a gbk type. Garbled characters occur when SQLyog is used to import data from csv files containing Chinese characters to the MySQL database. Symptoms: 1. directly import the CSV file. The data is imported successfully, but garbled characters are displayed in sqlyog. 2. use the insert statement to import and test sqlyog. garbled characters are displayed after data is saved. 3. run cmd

[Memo] My requirement is to unify the format into gbk.

Garbled characters occur when SQLyog is used to import data from csv files containing Chinese characters to the MySQL database.

Symptoms:

1. Directly import the CSV file. The data is imported successfully, but garbled characters are displayed in sqlyog;

2. Use the insert statement to import and test sqlyog. garbled characters are displayed after data is saved;

3. Use the cmd command line to operate mysql and check that the data is garbled; the direct insert operation is still garbled;

4... It's garbled...


Solution:

1. After the mysql service is disabled, modify my. ini in the mysql installation directory.

The default value is latin1. Set default-character-set = gbk. This attribute is assigned twice.

2. If you are not at ease, continue to the mysql data directory, such as my project test

C: \ ProgramData \ MySQL Server 5.1 \ data \ test, open the db. opt file,

Replace content

Default-character-set = gbk
Default-collation = gbk_chinese_ci

Save.

3. Start the mysql service and run the command to view the current encoding status.

We can see that most of them have become gbk ...... Only one character_set_system is utf8. But it doesn't matter,
According to the MySQL5.1 reference manual, this does not affect the metadata encoding.


4.
Some people have completed the previous steps, but I have encountered more trouble. I found a solution by myself and set charset to gbk on each column.
Reference URL: Click to open the link
So alter table xx .... ModifyYy varchar (30)Character setGbk;
Refer to the lz of the website to go here and it will be OK, but I still failed to import; then it is clear that I have to continue to adjust the format of the imported csv file;


5. Use notepad or UE to open the csv file and save it as gbk.
(I have been using notepad ++ to open and adjust the encoding mode. It seems that I have never been able ...)
When saving it as a file, I found that there is no gbk option... . However, after searching, you can select ansi... (It seems that ansi refers to local encoding)
For the sake of insurance, I did the following before saving it as ansi (using UE ):


Then we can just...
Try to save notepad as ansi.

Another day, it seems that we have to properly handle these codes .. It's too easy to confuse me.

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.