Export AWS RDS From One Account to Another Account or Region
Categories:
2 minute read
Take a snapshot of the RDS
- Open AWS RDS console in the source account https://console.aws.amazon.com/rds/home
- Make sure you are in correct region
- Select the required instance
- Click Actions -> Take snapshot
- Enter a name for snapshot
- Click Take Snapshot
- It would take about 5-10 minutes
- Make sure the status of the snapshot changed to Available
Share snapshot
- Select the snapshot (Checkbox)
- Click Actions -> Share snapshot
- Make sure DB snapshot visibility is private
- Enter the Target Account id
- Click Add
- Click Save
Share the KMS key
- Click the name of the snapshot
- Note the KMS key ID (If the id None then database is not encrypted skip this section)
- Open AWS KMS console https://console.aws.amazon.com/kms/home
- Select the kms key noted in previous step (make sure you have the correct region)
- Under Other AWS accounts -> Add other AWS account
- Click Add another AWS accounts
- Enter the target account id
- click Save changes
Restore snapshot
- Open AWS RDS console in Target Account https://console.aws.amazon.com/rds/home
- Click Snapshots in the left navigation
- Open Tab Shared with me
- Select the snapshot
- Click Actions -> Restore snapshot
- Enter Settings -> DB instance identifier
- if you are using DATA API then enable it Connectivity -> Additional configuration -> Enable Data API
- Select the required security groups (Create groups as in source if required)
- You may leave everything else default
- Click Restore DB Cluster
- It may take 15-30 mins to restore the db and then the status changes to Available
Change master password
- Open AWS RDS console https://console.aws.amazon.com/rds/home
- Select the restored instance (make sure the status is Available)
- Click Modify
- Set New master password (and note it in safe location)
- Click Continue
- Select Apply immediately
- Click Modify cluster
- It may take couple of minutes and then DB status change from Resetting-master-credentials to Available
Change app user password
- Open AWS RDS console https://console.aws.amazon.com/rds/home
- Select the restored instance
- Click Actions -> Query
- Login with master user
- Execute the following query to set the new password
MySQL 5.7.6 and later or MariaDB 10.1.20 and later
ALTER USER `appuser`@`%` IDENTIFIED BY 'app-pass';
FLUSH PRIVILEGES;
MySQL 5.7.5 and earlier or MariaDB 10.1.20 and earlier
SET PASSWORD FOR 'appuser'@'%' = PASSWORD('app-pass');
FLUSH PRIVILEGES;
Cleanup
Note: If the security group auto create option is selected when restoring snapshot then it may create a default inbound rule with the public IP of your computer. You may want to delete this inbound rule.