I am posting the resolution since it drove me crazy for a few days -- it turned out to be the AppArmor settings. This thread finally got me solved: How can I get around MySQL Errcode 13 with SELECT INTO OUTFILE?
I see this is marked as duplicate but all the other suggestions seem to point to editing my.cnf which is not working for me.
I cannot get Load Data Local Infile to work. My MySQL server version is 5.5.41 and my Ubuntu version is 14.04.2. My my.cnf has "local-infile" under mysql, mysqld and client. I am below specifying flag 128 in the connection string per another post on Stackoverflow. The code below works great when I run it on the client but now that it lives on the server it continuously throws
"The used command is not allowed with this MySQL version.
EDIT, running this from command line is successful:
mysql> LOAD DATA LOCAL INFILE '/home/aa/ER.csv'
-> INTO TABLE ER_import
-> FIELDS TERMINATED BY ','
-> LINES TERMINATED BY '\r\n'
-> IGNORE 1 LINES
-> (Paid_Amount,
-> Pro_Number,
-> Invoice,
-> Ship_Date,
-> BL,
-> Carrier_Name,
-> Check_Number,
-> Paid_Date,
-> Shipper_City,
-> Shipper_State,
-> Shipper_Name_1,
-> Recipient_City,
-> Recipient_State,
-> Recipient_Name_1,
-> Batch_Number,
-> Actual_Weight,
-> Billed_Amount
-> );
Query OK, 8585 rows affected, 4 warnings (0.21 sec)
Records: 8585 Deleted: 0 Skipped: 0 Warnings: 4
yet this keeps retuning that the file is not found: "File '/home/aa/ER.csv' not found (Errcode: 13)" the file is definitely there and permission are correct:
$delete = "DELETE FROM ER_import";
if (!mysqli_query($conn,$delete))
{
echo("Error description: " . mysqli_error($conn));
}
$query = <<<eof
LOAD DATA INFILE '/home/aa/ER.csv'
INTO TABLE ER_import
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(Paid_Amount,
Pro_Number,
Invoice,
Ship_Date,
BL,
Carrier_Name,
Check_Number,
Paid_Date,
Shipper_City,
Shipper_State,
Shipper_Name_1,
Recipient_City,
Recipient_State,
Recipient_Name_1,
Batch_Number,
Actual_Weight,
Billed_Amount
);
eof;
if($results = mysqli_query($conn, $query)){
echo $file. " has been imported!";
} else die(mysqli_error($conn));
Is it something obvious??