Convert MySQL table to CSV file
CSV is a field-separated format that can be easily imported into a spreadsheet application. Usually the separator field is a comma. However, sometimes it is easier to select a more unusual character (like “@” for example), so that the field separator is not confused with commas in the field values.
In the example below we will dump contents of table1 in database1 to /tmp/database1_table1.csv. On the command line type this:
mysql -udbuser -pdbpasswd << EOF SELECT * INTO OUTFILE '/tmp/database1_table1.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM database1.table1; EOF
Popularity: 2% [?]
Related posts:
- Exporting spreadsheet data to MySQL
- Creating table indexes in MySQL
- MySQL LOAD DATA Syntax
- The correct MySQL GRANT syntax
- Install PHP, Mysql, Apache2 on Solaris 9
- Useful awk one-liners
- MySQL query cache
- Using GNUPlot to chart MySQL data
- Find and Replace in MySQL
- Apache MySQL PHP Solaris 8 Installation


