1、windows做的csv文件默认是gbk字符集,而mysql设置了默认是utf8字符集,所以要把文件转为utf8格式。

iconv -f GBK -t UTF8  /tmp/文件名.csv -o /tmp/文件名2.csv


2、用sql命令导入

load data infile '/tmp/mailut2.csv' into table db1.d fields terminated by ',' lines terminated by '\n' ignore 1 lines (id,email,passwords,name,address,dept,mobile);


ignore 1 lines 是忽略第1行,第1行是标题行

(id,email,passwords,name,address,dept,mobile)  这里是指按这个字段顺序导入,即csv文件的第一列导入到表中的id字段,第二列导入email字段......

如果csv文件后面还有列,则忽略。