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);