If I want to save selected data from a table to an output file, I have to save it to the approved directory specified by the secure_file_priv variable. However, even If change the output file path to the approved directory, it still doesn't work, producing the following error- the same error I got before I started using the secure_file_priv specified directory:
mysql> SELECT * FROM customers
-> INTO OUTFILE " C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\output.txt";
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
Which had me nonplussed, since I had changed the directory to the appropriate directory specified by secure_file_priv, I shouldn't be getting that error any longer. Hoewever, when I changed the backslashes in the path to forward slashes, the query worked, and created the file.
mysql> SELECT * FROM customers
-> INTO OUTFILE "/ProgramData/MySQL/MySQL Server 5.7/Uploads/output.txt";
Query OK, 2 rows affected (0.00 sec)
Why is that? I did all of this on Windows via the command line, so I don't see why I had to use forward slashes, almost as if I was working on a *nix system.