1

I have an ec2-instance on which mysql database is there and now there are multiple tables have huge values which i want to export into an excel sheet into my local system or even some place at S3 will also work , how can i achieve this ?

Vatsal Rahul
  • 347
  • 1
  • 4
  • 19
  • Possible duplicate of [Mysqldump in CSV format](https://stackoverflow.com/questions/12040816/mysqldump-in-csv-format) – Jacob Dec 27 '18 at 06:18

2 Answers2

2

Given that you installed your own MySQL instance on an EC2 node, you should have full access to MySQL's abilities. I don't see any reason why you can't just do a SELECT ... INTO OUTFILE here:

SELECT *
FROM yourTable
INTO OUTFILE 'output.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

Once you have the CSV file, you may transfer it to a box running Excel, and use the Excel import wizard to bring in the data.

Edit:

Based on your comments below, it might be the case that you need to carefully select an output path and location to which MySQL and your user have permissions to write.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
1

Another way to export CSV files from RDS Mysql and without getting Access denied for user '<databasename>'@'%' (using password: YES) is doing the following command:

mysql -u username -p --database=dbname --host=rdshostname --port=rdsport --batch -e "select * from yourtable" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > yourlocalfilename.csv

The secret is in this part: --batch -e "select * from yourtable" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > yourlocalfilename.csv

Thiago Valentim
  • 500
  • 6
  • 14