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

mysql load data infile specify columns
mysql load data infile limit rows
mysql load data infile ignore column
mysql load data infile access denied
mysql load data infile date format
mysql 5.7 load data infile
load data local infile the used command is not allowed with this mysql version
docker mysql load data infile

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?

How to Import Data From Text File Using MySQL Query, The LOAD DATA INFILE statement allows you to read data from a text file and import the file's data into a database table very fast. Before importing the file, you​  MySQL LOAD DATA INFILE Query running successfully but no output Tag: mysql , csv I am running an SQL statement to read in a CSV file (in this case only 1 column with a heading) and importing it into my database, where further manipulation to the data will occur through subsequent SQL statements.

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 ...

mysql> USE db1; mysql> LOAD DATA INFILE "./data.txt" INTO TABLE db2.​my_table;. The REPLACE and IGNORE keywords control handling of input records that  For the mysql client, local data loading capability is determined by the default compiled into the MySQL client library. To disable or enable it explicitly, use the --local-infile=0 or --local-infile[=1] option.

In my case, LOAD DATA INFILE is a success with the first dataset. But with the second dataset, I've got this errcode 13.

What I did (win user), I press CTRL+ALT+DELETE and then I selected Start Task Manager, then I went to the processes tab and selected Excel then pressed End Task.

Then tried again the LOAD DATA INFILE and it worked.

Note: Before this, I tried to open the CSV file just to check the dataset. It took too long, therefore, I closed it immediately before the file opened.

Maybe the incomplete process disturbed the load process.

I'm not sure with PHP because I just using phpmyadmin and play with MySQL

If you have data in a text file, you can easily upload them to one or more tables in a database. In MySQL database (or MariaDB), using “load  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more MySQL LOAD DATA INFILE with auto increment

How do I insert data into a MySQL database from a text file?

to your hosting account and then add the path to the query.

If you write a data file with mysqldump -T or with the SELECT INTO OUTFILE statement with the mysql client, be sure to use the 

Comments
  • i faced a similar issue like this and nothing works then had to changed to win server
  • This solution worked for me. In order to set permissions, I first executed chmod($fileName, 0777); theoretically a security risk, but I delete the file at the end of the import operation.