csv导入数据到mysql

时间:2023-03-08 16:46:30

csv表中含有中文字符,具体实现代码示例:

load data infile 'C:\\Users\\Administrator\\Desktop\\import\\CELLutf.csv' into table cell character set gbk(设置gbk字符编码,防止出现中文乱码)
fields terminated by ','
enclosed by '"'
lines terminated by '\r\n'
IGNORE 1 LINES;

代码解释:

fields terminated by ',':csv文件中数据之间的分隔符,csv文件默认以逗号分隔;

enclosed by '':指出封套符;

lines terminated by '':指行终止符;

IGNORE 1 LINES:忽略csv表头。