Select Page

In this article, we’ll discuss how to create a MySQL Read Replica in a different AWS account.

Let’s clarify a few things:

  1. You have a Primary AWS account with RDS MySQL database
  2. You have a secondary AWS account where you wanna create a Read Replica

Before we start I should mention that you should do it pretty quickly, to avoid delays

So let’s start, just follow step by step instruction below:

  1. Create a read replica in a first account, let’s call it Temp-Read-Replica – it’ll be a temporary read replica, and we’ll remove it after we finish the process
  2. Verify there are a peering connection and SG configured between Account 1 and Account 2, you should be able to reach subnets where databases will be located
  3. Login to Temp-Read-Replica and run command ”
    call mysql.rds_stop_replication
  4. Take a snapshot from the Temp-Read-Replica
  5. Share this snapshot to Account 2
    1. if you have a custom KMS key need to copy snapshot in Account 1 and change KMS key
  6. Create a new RDS instance from that shared snapshot in Account 2
  7. Connect to old replica from Account 1 and run ”
    show slave status \G
    1. Take 2 parameters: Master_Log_File and Exec_Master_Log_Pos
  8. Connect to a new RDS from Account 2 and run the command
    call mysql.rds_set_external_master('<RDS_HOST_FROM_ACCOUNT_1>', 3306, '<MASTER USERNAME>', '<MASTER PASSWORD>', '<value from Master_Log_File>', <Value from Exec_Master_Log_Pos>, 0);
  9. Now we should start replication – execute this command on a new RDS
    call mysql.rds_start_replication;
  10. Then run the command
    show slave status \G

    to see that there are no errors and Second_Behind_Master is going down

  11. When Second_Behind_Master is “0”, you can delete the Temp-Read-Replica