I am learning MySQL and tried using a LOAD DATA
clause. When I used it as below:
LOAD DATA INFILE "text.txt" INTO table mytable;
I got the following error:
The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
How do I tackle this error?
I have checked another question on the same error message, but still can’t find a solution.
I am using MySQL 5.6
I had the same problem with 'secure-file-priv'. Commenting in the .ini file didn't work and neither did moving file in directory specified by 'secure-file-priv'.
Finally, as dbc suggested, making 'secure-file-priv' equal to an empty string worked. So if anyone is stuck after trying answers above, hopefully doing this will help.
It's working as intended. Your MySQL server has been started with --secure-file-priv option which basically limits from which directories you can load files using
LOAD DATA INFILE
.You may use
SHOW VARIABLES LIKE "secure_file_priv";
to see the directory that has been configured.You have two options:
secure-file-priv
.secure-file-priv
. This must be removed from startup and cannot be modified dynamically. To do this check your MySQL start up parameters (depending on platform) and my.ini.I had all sorts of problems with this. I was changing my.cnf and all sorts of crazy things that other versions of this problem tried to show.
What worked for me:
The error I was getting
The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
I was able to fix it by opening /usr/local/mysql/support-files/mysql.server and changing the following line:
to
I had this problem on windows 10. "--secure-file-priv in MySQL" To solve this I did the following.
The server started up as expected.
I had the same issue. I finally solved using the
LOCAL
option in the commandLOAD DATA LOCAL INFILE "text.txt" INTO TABLE mytable;
You can find more info here http://dev.mysql.com/doc/refman/5.7/en/load-data.html
I'm working on MySQL5.7.11 on Debian, the command that worked for me to see the directory is:
mysql> SELECT @@global.secure_file_priv;