導入csv:
復制代碼 代碼如下:
load data infile '/test.csv' into table table_name
fields terminated by ',' optionally
enclosed by '"' escaped by '"'
lines terminated by '\r\n'
ignore 1 lines;
導csv:
復制代碼 代碼如下:
SELECT * INTO OUTFILE '/test.csv'
FIELDS TERMINATED BY ',' OPTIONALLY
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table_name;
解決導出csv中文亂碼問題:
將csv用txt打開,另存為,選擇utf8編碼即可。
解決導入問題:
mysql安裝目錄下的my.ini,增加如下參數:
[client]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
重啟mysql服務。