MySQL uses load data local infile to import part of the data after the Chinese garbled

Source: Internet
Author: User

Today, between the two MySQL servers to guide the data, because another MySQL server is testing, one months of data, from the existing MySQL server Select to a file, the specific statement is:

* FROM news where Ine_time>=<"/tmp/newsdata.sql";   

Then SCP to another MySQL online poker room server to import into the corresponding table, the specific statement is as follows:

"/home/lsanotes/newsdata.sql" into table news;

And then refresh the Web page to access this database, found that the first one months of data are garbled, and the other months before the normal, with show create TABLE news, see found two servers in the news table is UTF8, strange, to convert the exported data into UTF8, The problem of re-importing is still.
Later in the database to view the one months of data that just entered, did not execute set names UTF8; you can normally view Chinese without garbled, and other months must first execute set names UTF8; to see Chinese without garbled, but when I executed set names UTF8; And then see just the one months of data is garbled, it seems that the data is not UTF8 format. The Final Solution is:

"/home/lsanotes/newsdata.sql" into table news character set UTF8;
The last Web page appears normal.

Http://www.lsanotes.cn/load-data-local-infile

MySQL uses load data local infile to import part of the data after the Chinese garbled

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.