I am running mysql version 5.7.27 for Linux on a remote server.
I have a php Script that should load some big csv files into a database via following code
$query = "LOAD DATA INFILE
'C:/some/big/file/file.csv'
REPLACE INTO TABLE csv_table
CHARACTER SET UTF8
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES";
The script is running normally but mysql sends out the following error:
Errormessage: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
I already did a lot of googling about this error and eventually found some helpful tips about how to set the variable and what to set: https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_secure_file_priv I also learned mysql will look at 3 places for the configuration:
/etc/my.cnf
/etc/mysql/my.cnf
/usr/local/etc/my.cnf ~/.my.cnf
in respective order.
The my.cnf includes etc/mysql/mysql.conf.d file so I put the following line there
[mysqld]
secure_file_priv = '/home/my/folder/'
When I check the setting via
SHOW VARIABLES LIKE 'secure-f%';
I get the correct value!
But when I try to execute the script, I still receive the same old error message. Since the setting is correctly printed, I am not sure what to make of this.
Please help me figure out how to get rid of this error. Thanks
EDIT:
Thanks for the hint! It's embarassing but it was really like you said. I tested locally (worked) and copy pasted the code onto the server, where there is no C:/ .. of course. Thank you. After this I got a different error which could be solved with the help of this: LOAD DATA INFILE Error Code : 13