SQL into outfile - where is the file stored? (MySQL, Windows)
12,995
Be default it stored in the MySQL's data directory. And you can check your data directory by command:
show variables like 'datadir';
You can't store it locally with this command running on remote server, you need to download the file from the server.
You can also use this command:
SELECT * FROM table INTO OUTFILE 'mysqlresults.csv' FIELDS TERMINATED BY ','OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' ;
Author by
tsotsi
Updated on June 18, 2022Comments
-
tsotsi almost 2 years
I am using MySQL and would like the results of the following query to be stored in a csv file locally on my machine:
SELECT * INTO OUTFILE 'mysqlresults.csv' FIELDS TERMINATED BY ','OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM table;
I have searched for the file and it could not be located anywhere on the disk so it is not in the 'data' directory.