Exporting table from Amazon RDS into a csv file

前端 未结 6 1368
后悔当初
后悔当初 2020-11-29 17:43

I have a mysql database running in Amazon RDS, and I want to know how to export an entire table to csv format. I currently use mysql server on Windows to query the Amazon da

6条回答
  •  北海茫月
    2020-11-29 18:22

    If you use the solution marked as correct, you'll notice that it generates a header that includes the 'concat' string literal. Obviously this is not what you want. Most likely you will want the corresponding headers of your data. This query will work without any modifications, other than substituting column names and table names:

    mysql -h xxx.xxx.us-east-2.rds.amazonaws.com 
    --database=mydb -u admin -p 
    -e "SELECT 'column1','column2' 
    UNION ALL SELECT column1,column2 
    FROM table_name WHERE condition = value" > dataset.csv
    

    I just opened the results in the Numbers osx app and the output looks perfect.

提交回复
热议问题