Tips on dumping RDS database, in particular MySQL to localhost Show I bet you had a situation when you had to dump production database for some investigation, testing or even development. Off topic: Usually the production DB is secured in AWS VPC (virtual private cloud) and nobody should connect directly without VPN. Often it happens that the DB is only accessible from a server inside VPC which serves as a “bastion” server so that you can access other servers inside VPC from this server but not from public. Below are a few tips which you may find useful in these circumstances:
ssh -i ssh_key.pem \ This command will ssh to the bastion server and execute 2. If you’re not brave enough to dump DB from command line and you prefer to use some graphic tools like Sequel Pro you can still do it using
ssh reverse tunnel. ssh -i ssh_key.pem -N -L LOCAL_PORT:rds.host:RDS_PORT When it runs you should be able to connect with your favourite SQL client, e.g.: 3. If you dump or restore large DBs it can be tricky to see progress. Usually the command looks like hanging, e.g. for restore: mysql -P DB_PORT -u dbuser — password=dbpassword dbname < dumpfile There is a nice but not so well known tool on *nix systems called Pipe Viewer which can help in tracking progress. Here is an example usage:
mysqldump -P 3306 -h rds.host -u dbuser — password=dbpassword dbname | pv -W > dumpfile
pv dumpfile | mysql -P DB_PORT -h db.host -u dbuser — password=dbpassword dbname Then you see a nice progress bar from Pipe Viewer: Pipe Viewer in actionThanks for reading! Feel free to hit the recommend button below if you found this piece helpful. You can connect with me on Twitter or subscribe to my mailing list if you want to get occasional info about my recent work. How do I restore a MySQL dump file?How to Restore MySQL with mysqldump. Step 1: Create New Database. On the system that hosts the database, use MySQL to create a new database. ... . Step 2: Restore MySQL Dump. ... . Step 1: Create a MySQL Database Backup. ... . Step 2: Clear the Old Database Information. ... . Step 3: Restore Your Backed up MySQL Database.. How do I import a dump file into AWS RDS?FREMOVE , found on the Oracle website.. Step 1: Grant privileges to the database user on the RDS for Oracle target DB instance. ... . Step 2: Export data into a dump file using DBMS_DATAPUMP. ... . Step 3: Upload the dump file to your Amazon S3 bucket. ... . Step 4: Download the dump file from your Amazon S3 bucket to your target DB instance.. How do I restore AWS RDS MySQL database?In the top right corner of the Amazon RDS console, choose the AWS Region in which to create your DB instance. Choose the same AWS Region as the Amazon S3 bucket that contains your database backup. In the navigation pane, choose Databases. Choose Restore from S3.
How do I restore a MySQL database dump file in Linux?Use the mysql command to restore a database from the command line. In MySQL, you can use the mysql command to restore the database from a dump file. mysqldump is a command-line utility used to generate a MySQL logical database backup as a single . sql file with a set of SQL statements.
|