CVS file import mysql database command:
| The code is as follows |
Copy Code |
Set names UTF8; LOAD DATA local INFILE ' c:\\resource.csv ' into TABLE Resource FIELDS terminated by "" LINES terminated by ' \ r \ n ' (Title,singer); |
FIELDS terminated by----field terminating character
Optionally enclosed by----envelope character
LINES terminated by----line terminator
Export data for a period of time to CVS:
| code is as follows |
copy code |
| filename= "Data" ' Date--date= $date ' +%y%m%d ' ' ". csv '; #mysql里先导出数据到 XML, with Select INTO OutFile export, set field separator and record delimiter /usr/local/webserver/mysql/bin/mysql-h "$mysql _host"-u "$mysql _username"-- password= "$mysql _password" -E "select * into outfile ' $data _dir$filename ' FIELDS terminated by ', ' optionally Enclosed by ' LINES terminated by ' \\n ' from $table where intime>= $minTime && intime< $maxTim e; " #这一步也很重要, you need to convert the encoding to GBK RM-RF $final _dir$filename && touch $final _dir$filename iconv-c -F UTF-8 -T gbk $data _dir$filename > $final _dir$filename |
Use the SELECT into outfile to pour the data out of MySQL, where the field delimiter is \ t, the record delimiter is \ n, and then the encoding of the character is turned on OK!