问题描述
在这里阅读了几个答案之后,我终于弄清了为什么没有通过命令提示符加载我的.csv文件的原因.我必须启用加载数据本地文件.一旦这样做,我就读取了全局变量,并且它们处于启用状态.这样我就可以加载数据了.但是,在关闭命令提示符后,我重新打开了该窗口,并且当变量仍读为ON时,它不允许我导入另一个.csv文件.我是否需要关闭本地infile并重新打开才能再次工作
After reading several answers on here, I finally figured out why my .csv file wasn't loading in through the command prompt. I had to enable load data local infile. Once I did that, I read the global variables and they were on. I was able to load the data then. However, after closing the command prompt, I reopened it and while the variable was still reading as ON, it wouldn't allow me to import another .csv file. Do i need to turn local infile off and back on for it to work again
这是我试图用来上传的代码.它是第一次工作(甚至不是30分钟前),但现在不起作用
this is the code that I am attempting to use to upload. It worked the first time (not even 30 minutes ago), but now it won't work
load data local infile '…\\Mod 8\\Vehicles_2016.csv'
into table vehicles_2016
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
ignore 1 lines
(@col1, @dummy, @dummy, @col2
,@dummy, @dummy, @dummy, @dummy, @dummy
,@dummy, @dummy, @dummy, @dummy, @dummy
,@dummy, @dummy, @dummy, @dummy, @dummy
,@dummy, @dummy, @dummy, @dummy, @dummy
)
set accident_index=@col1,vehicle_type=@col2;
此外,我尝试在加载之前关闭全局变量并重新打开它,但这没用.
Additionally, I tried turning off the global variable and turning it back on before loading, but that didn't work.
推荐答案
每个mysql客户端连接都需要使用"--local-infile"或数据库API中的相应选项来启动.
Each mysql client connection needs to be started with '--local-infile' or the corresponding option in the database API.
这篇关于MySQL:启用LOAD DATA LOCAL INFILE重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!