简体   繁体   中英

sql query result to csv file directly from console

I want to export select query result with two columns to csv file. I don't have phpmyadmin or tools like this. I have to run my query directly from console. Can someone give me a hint how can I do this?

You could try to use this command:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM