导入.csv文件到mysql数据库

首先通过如下命令获取到mysql的secure_file_priv的值:

show variables like '%secure%'

secure_file_priv 的值是在对mysql导入导出csv文件时的路径,mysql的文件只能导入导出到此路径,我的的mysql数据库的

secure_file_priv的值为C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/

然后运行如下命令:

load data local infile 'C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/user.csv'

into table t_user

fields terminated by ','

optionally enclosed by '"'

-- escaped by ','

escaped by '"'

lines terminated by '\r\n'

ignore 1 lines;

20多万条记录很快就导入,非常快!

猜你喜欢

转载自blog.csdn.net/m0_37561039/article/details/83552613