1

When I try to run this command

select name, address, age into outfile 'user.csv' FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n' from StudentTable;"

I got an error from MySql:

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

Makdous
  • 1,447
  • 1
  • 12
  • 24
Aman Gupta
  • 140
  • 2
  • 10
  • Refer the [post](https://stackoverflow.com/questions/32737478/how-should-i-tackle-secure-file-priv-in-mysql) and it can help you. – Karthick Apr 26 '20 at 17:30

1 Answers1

1

Use

SELECT @@secure_file_priv;

To see what Folder is secure.

If it returns f.e

C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\

Use

select name, address, age into outfile 'C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Uploads\\user.csv' 
    FIELDS TERMINATED BY ',' 
    LINES TERMINATED BY '\n' 
from StudentTable;

the Backslashes must be doubled

To disable change in he my.ini file

[mysqld]
secure-file-priv = ""

But that is insecure, because you can save anywhere you have write rights, bit alsoo there mus specify the folder where you want to write it for example

c:\\temp\\user.csv
nbk
  • 45,398
  • 8
  • 30
  • 47