问题
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
EDIT: 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.
回答1:
Each mysql client connection needs to be started with '--local-infile' or the corresponding option in the database API.
来源:https://stackoverflow.com/questions/54623557/mysql-enable-load-data-local-infile-reset