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.
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' ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With