I know this has been asked before but I could not find any newer posts that could be of help. LOAD DATA LOCAL INFILE has been working perfectly up until today. I have not changed anything other than ran an update for PHP and (not sure but I think) MariaDB. I am running now PHP 7.2.17 and MariaDB 10.1.38
Now I get this error: Warning: mysqli::query(): LOAD DATA LOCAL INFILE forbidden
I checked what I could find: - db user has all rights, even root user gets this error - checked my.cnf for entry local-infile=1
Load statement works fine within mysql commandline but not in PHP script.
Here is how I run the import:
define ('DB_USER', "db_user");
define ('DB_PASSWORD', "my_password");
define ('DB_DATABASE', "prosjekt");
define ('DB_HOST', "localhost");
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
I get the error on the last line -> $mysqli->query($query);
$query = <<<eof
LOAD DATA LOCAL INFILE '$fileName'
INTO TABLE prosjekt
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r'
(prosjektnavn,prosjektstatus,prosjektbesk,oppdragsgiver,prosjektans,prosjektdelt,start,slutt,prosjektnr,prosjekttype,sortnr,ant_rapport,litt_link)
eof;
$mysqli->query($query);
So I can run this fine in mysql console but not in a PHP script, and it starting failing today. Any ideas how to fix it? When I run SHOW VARIABLES; I get this so it should work?
local_infile ON