Search code examples
mysqlsqldatabasecsvload-data-infile

secure-file-priv preventing INTO OUTFILE command


I'm using:

SELECT * FROM accounts INTO OUTFILE("C:/Users/Home/Documents/test.txt")

but I get the error:

(db:1290) The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

I don't have permission to change the security settings of the database but was wondering if there was some alternative command that would work around this problem. Thank you


Solution

  • In your MySQL server's config, put this line under the [mysqld] and restart the Service

    secure_file_priv=/tmp/ #the dir you want to put the result file
    

    Or

    mysql -s -e 'SELECT * FROM accounts' | cat > /path/to/file