Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL LOAD DATA INFILE "not found (Errcode: 13 - Permission denied)"

Last week this was working, and today it isn't. I have not changed the php file. All I have done in the interim is run apt-get update on my Ubuntu 15.04 server.

The MySQL statement I have is:

LOAD DATA INFILE "/var/www/html/uploads/TitleList.csv" INTO TABLE tblLSITitleList FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY "\"" IGNORE 5 LINES;

This gives the following error:

File '/var/www/html/uploads/TitleList.csv' not found (Errcode: 13 - Permission denied)

I have tried the following solution (which was how I solved this exact problem early last week: LOAD DATA INFILE Error Code : 13

I have checked the apparmor and the uploads folder is still there.

I have also tried chmodding various permissions, including 777, but nothing helps.

Any clever suggestions?

like image 930
Neill Avatar asked Jun 10 '15 15:06

Neill


1 Answers

From the docs:

For security reasons, when reading text files located on the server, 
the files must either reside in the database directory or be 
readable by all

I recommend copying your .csv file to database directory, something like

cp TitleList.csv /var/lib/mysql/yourdbname/TitleList.csv

and then

LOAD DATA INFILE 'TitleList.csv' INTO etc ...
like image 102
Herokiller Avatar answered Oct 24 '22 02:10

Herokiller