

To do this, edit the my.cnf file, find the line that specifies secure-file-priv, and set it to a directory where you want to allow files to be loaded from, like:Īfter making this change, you’ll need to restart the MySQL server for the changes to take effect.Ģ. Change the MySQL server configuration: You can modify the my.cnf configuration file for MySQL to change the value of the secure-file-priv option.To resolve this error, you have a few options: If you see the error message The MySQL server is running with the -secure-file-priv option so it cannot execute this statement while trying to load data from a file using the LOAD DATA INFILE statement, it means that the MySQL server is configured to restrict the locations from which files can be loaded. In general, it’s recommended to keep -secure-file-priv enabled and only allow access to files from trusted directories. You can also load or export data using other tools or methods, such as the MySQL mysqlimport utility, a database management tool such as phpMyAdmin, or an ETL (extract, transform, load) tool like Apache NiFi. To do this, add the following line to the configuration file: secure-file-priv=""īe aware that disabling -secure-file-priv may introduce security risks if you’re not careful about the files you load or export.ģ. If you don’t want to move the file, you can disable -secure-file-priv altogether by setting it to an empty string in your MySQL configuration file (usually located at /etc/mysql//mysqld.cnf).

You can check the current value of this option by running the following query:īy default, MySQL sets -secure-file-priv to the value of the datadir system variable, which is usually /var/lib/mysql on Linux systems.Ģ. Move the file to a directory that is permitted by the -secure-file-priv option.To resolve this issue, you have several options: If you’re getting an error related to -secure-file-priv, it’s likely that you’re attempting to load or export data using one of the above statements and the file is not located in a permitted directory.
