MySQL export XLS and CSV data implementation and garbled solution

Source: Internet
Author: User
Tags mysql tutorial mysql command line

MySQL tutorial export XLS and CSV data implementation and garbled solution
Following about
First look at MySQL Export import xls and CSV data instance methods, while encountering the import of garbled when the effective solution,

Execute the following SQL statement under the MySQL command line:

Mysql>select * from xi_table into outfile ' D:www.111cn.nettest.xls ';

Sometimes when Excel is turned on, it will appear garbled,
Because office defaults to gb2312 encoding, server-side generation is likely to be utf-8 encoded, which can be encoded using ICONV on the server side: Iconv-futf8-tgb2312-otest2.xls Test.xls

If you do not have server management permissions, you can use the following methods to solve the garbled problem

First download the Test.xls down, this time the file is Utf-8 encoded, with Excel open, garbled.
Open the Test.xls as text, and then save as, in the encoding, select ANSI encoding, saving.
So again with Excel open, garbled problem is solved.


Then look at the MySQL export CSV write file directory needs to be MySQL has Write permission directory.

Export

Select Field1,field2,field3 from tablename to outfile '/home/output1.csv ' fields terminated by ', ' optionally enclosed by ' Lines terminated by ' n ';

Import

Load data local infile '/home/output1.csv ' to table tablename fields terminated by ', ' lines terminated by ' n ' (field1,fie LD2,FIELD3);

Related Article

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.