Result of sql query to csv file directly from the console

I want to export the result of a query selectwith two columns to a file csv. I do not have phpmyadmin or such tools. I need to run my request directly from the console. Can someone give me a hint how can I do this?

+4
source share
1 answer

You can try using this command:

SELECT field_1,field_2
FROM table_name
INTO OUTFILE '/tmp/output.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
+6
source

All Articles