Export AWS RDS From One Account to Another Account or Region

Take a snapshot of the RDS

  1. Open AWS RDS console in the source account https://console.aws.amazon.com/rds/home
  2. Make sure you are in correct region
  3. Select the required instance
  4. Click Actions -> Take snapshot
  5. Enter a name for snapshot
  6. Click Take Snapshot
  7. It would take about 5-10 minutes
  8. Make sure the status of the snapshot changed to Available

Share snapshot

  1. Select the snapshot (Checkbox)
  2. Click Actions -> Share snapshot
  3. Make sure DB snapshot visibility is private
  4. Enter the Target Account id
  5. Click Add
  6. Click Save

Share the KMS key

  1. Click the name of the snapshot
  2. Note the KMS key ID (If the id None then database is not encrypted skip this section)
  3. Open AWS KMS console https://console.aws.amazon.com/kms/home
  4. Select the kms key noted in previous step (make sure you have the correct region)
  5. Under Other AWS accounts -> Add other AWS account
  6. Click Add another AWS accounts
  7. Enter the target account id
  8. click Save changes

Restore snapshot

  1. Open AWS RDS console in Target Account https://console.aws.amazon.com/rds/home
  2. Click Snapshots in the left navigation
  3. Open Tab Shared with me
  4. Select the snapshot
  5. Click Actions -> Restore snapshot
  6. Enter Settings -> DB instance identifier
  7. if you are using DATA API then enable it Connectivity -> Additional configuration -> Enable Data API
  8. Select the required security groups (Create groups as in source if required)
  9. You may leave everything else default
  10. Click Restore DB Cluster
  11. It may take 15-30 mins to restore the db and then the status changes to Available

Change master password

  1. Open AWS RDS console https://console.aws.amazon.com/rds/home
  2. Select the restored instance (make sure the status is Available)
  3. Click Modify
  4. Set New master password (and note it in safe location)
  5. Click Continue
  6. Select Apply immediately
  7. Click Modify cluster
  8. It may take couple of minutes and then DB status change from Resetting-master-credentials to Available

Change app user password

  1. Open AWS RDS console https://console.aws.amazon.com/rds/home
  2. Select the restored instance
  3. Click Actions -> Query
  4. Login with master user
  5. 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.

Ref: