1

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.

Mack623
  • 13
  • 1
  • 6

1 Answers1

2

Each mysql client connection needs to be started with '--local-infile' or the corresponding option in the database API.

danblack
  • 12,130
  • 2
  • 22
  • 41
  • 1
    So you mean that when I log in, rather than JUST the mysql -u username -p password, I need to add in --local-infile? So mysql -u username -p --local-infile password? – Mack623 Feb 11 '19 at 04:20
  • well `mysql -u username -ppassword --local-infile` because `-p` relates to the password. – danblack Feb 11 '19 at 04:24