I’m learning MySQL and have set up a custom non-WordPress site (as per torquemag), deleted all the WordPress files, and imported a MySQL database not of WordPress origin. I am using MySQL Workbench and attempting to export the file to a TSV (tab-separated CSV) with this code:
/* Export data into TSV */
SELECT * INTO OUTFILE '/tmp/dump.csv'
FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
FROM videos;
When I run the command I get this error:
Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
I tried a couple possible solutions, but all failed:
Created a my.ini file in the conf/mysql folder as per this video, and added this code:
secure-file-priv=""
Renamed file to my.ini.hbs, but no-go. In fact, this is the error message from Local:
Ran each of these commands to get the secure file location, but the result is NULL for each:
select @@secure_file_priv;
show variables like "secure_file_priv";
SELECT @@GLOBAL.secure_file_priv;
I’m not sure where to go from here. I just want the SQL export command to be successful and I don’t see anything in the code that should be throwing that --secure-file-prive error.
… To make matters worse, I closed LocalWP, deleted the my.ini.hbs file, restarted Local. But, now the site won’t start and Local keeps throwing the my.ini site can't start error.
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.
We don’t explicitly add that flag when MySQL starts, and a value of NULL means that reading/writing data is disabled.
I think the issue is that you need to explicitly configure MySQL to have a certain folder to write to. I didn’t try this with a blank site, but I think it’s the same process. Basically:
Update my.cnf.hbs to point to a specific folder
Restart the site so the configuration file is compiled and loaded
Ensure the value is set correctly
Run your query
I was able to do this with wp_posts data, so maybe this should work for you too?
That seems to rule Workbench out as the root of the issue.
Next, I tried a Unix-style path like this,
secure-file-priv="/c/Users/erich/Downloads"
But, that gives me the “Uh-oh! Unable to start site” error from before.
Any ideas? Perhaps this is Windows-specific and somebody can test on a Windows computer?
ALSO: As a side note, I tried adding that to my.cnf.hbs as an attempt before I posted for help originally. I added the secure-file-priv definition immediatedly under the [mysqld] and I also tried adding it at the bottom as the very last statement. Why didn’t any of those attempts work?
A little more detail about how I got there. I noticed that when I used single back slashes, my username of ben.turner was getting mangled with the inclusion of the bell character. For example, C:\Users\ben.turner\Downloads was turning the \b into a “bell” escape code. I fixed that by escaping the backslashes, so something like:
C:\\Users\\ben.turner\\Downloads
I would imagine that you would have something similar with \erich being interpreted as <escape-sequence>rich
You could use forward slashes instead, because it seems that Windows converts those correctly, and then you don’t need to type out backslash twice. Anyway, can you give that a shot and let me know how it goes?
Thanks Ben! I’m catching up with work after returning from vacation, so I honestly cannot say when, but hopefully I will find time to test this out soonish