How to export database from Amazon RDS MySQL instance to local instance?

MysqlAmazon Web-ServicesAmazon Ec2ExportAmazon Rds

Mysql Problem Overview


AWS documentation has this page that talks about importing and exporting data from MySQL server, but it's mostly about import. The only thing I see in their documentation is a way to export 5.6 data using replication, which is documented here. I was wondering if there is a simpler way to export data using mysqldump and load in local database. The database that I want to export is not huge, may be 1GB, so size is not a issue.

Mysql Solutions


Solution 1 - Mysql

Sure.

Take the dump from the remote RDS Server:

mysqldump -h rds.host.name -u remote_user_name -p remote_db > dump.sql

When prompted for password, provide the password for user=remote_user_name (remote server)

Upload it to your local mySql instance:

mysql -u local_user_name -p local_db < dump.sql

Also, if you own an ec2 server in the same region, I'd suggest take a dump there. zip the file and then scp it to your local machine. Typically, the compressed version of the file would be much smaller and you'd be able to transfer it quicker.

Solution 2 - Mysql

To export db from RDS

mysqldump -h rds.host.name -u remote_user_name -p remote_db > remote_db.sql

When prompted for password, provide the password

To import db on RDS

mysql -h rds.host.name -u remote_user_name -p remote_db < remote_db.sql

When prompted for password, provide the password

Solution 3 - Mysql

Another very easy option is by using the MySql Workbench. In the toolbar select 'Database' and 'Data export'. Select the right options, the target file ... and you're done! Easy does it!

Solution 4 - Mysql

This is an old topic, but in case you are getting the following error:

> Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=O FF. To make a complete dump, pass --all-databases --triggers --routines --events.

> mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buck ets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'db_name' AND TABLE_NAME = 'wp_actionscheduler_actions';': Unknown table 'COLUMN_STATISTICS' in information_schema

Simply, use the following command:

mysqldump -uUSER -p DATABASE --host=WriterEndpointNOport --set-gtid-purged=OFF --column-statistics=0 > bd_export.sql

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSrini KView Question on Stackoverflow
Solution 1 - MysqlTJ-View Answer on Stackoverflow
Solution 2 - MysqlKrishan Kumar MouryaView Answer on Stackoverflow
Solution 3 - Mysqltm1701View Answer on Stackoverflow
Solution 4 - MysqlHugo PinedaView Answer on Stackoverflow