Error connecting to migrated RDS (from another aws account) from ec2 - mysql

So we have two AWS accounts - one for stage and other for production. Now in stage, there is ec2 in public subnet and rds in private subnet. Ec2 and rds are connected to each other. Data is also populated in stage environment's rds.
Now we have migrated this ec2 and Rds to production aws account.
So the steps I followed for rds migration :
Created rds snapshot in stage -> copy snapshot -> share snapshot with production.
Opened production account -> copied shared snapshot -> Restore snapshot.
But now when trying to connect to this new migrated rds from production ec2 via Mysql workbench, it is giving error "Failed to connect to Mysql at xxxx...:3306 with user xxxx. Host private_ip_of_ec2 id not allowed to connect to this mysql server"
Stange thing, I tried crreating a new rds in production aws account, and it can be easily connected from ec2. Only the migrated rds from stage aws account does not connect.
Can somebody help in this issue ?
Note :
rds master username and password are same in both stage and production accounts.
ec2 was in public subnet in stage, but in production it is in private subnet.

Related

Connection failed to MySQL after upgrade AWS RDS instance

I have upgrade instance class of mysql rds on aws from tiny to small. After it complete upgrading I cannot connect to that database from my local machine.
I'm very new to aws rds please help.
(I use dbeaver and mysqlworkbench to test connection on my macbook)
I also try create new one with the same security group without encryption the new database connection works fine!

Scheduled DB imports in serverless RDS (opposite of mysqldump?)

I'm working on a project which for a long time will still be running alongside its predecessor. I need to import part of the old DB every 30 minutes.
In a testing environment, I used this solution:
run mysqldump from the source host (siteground.com) in a cronjob. Authorize the Siteground IP in the destination host.
In production I'm using a serverless AWS RDS instance, which cannot have public access.
What can I do?
Is there a way to pull the database tables in bulk (Siteground -> AWS) running the command from the AWS side?

AWS RDS vs MySql database directly on EC2

I created MySql database directly on EC2 instance (I host there my web app and database), I didn't set up RDS. But my database constantly keep crashing. So now I want to use RDS.
How to integrate my existing databases on EC2 with RDS?
By integrate I mean simply how to migrate them to RDS that they stop crashing on EC2 instance. Do I have to remove them from EC2, stop mysqld service on EC2 and then create them from scratch on RDS and change database access configurations in my apps or is there simpler way?
Unload your data from the SQL instance into CSVs. Put it into S3. Terminate your EC2 instance. Spin up RDS instance. Load data out of S3 into RDS. Job done.

How Ruby on rails works with Amazon RDS

I have a ruby on rails run on amazon ec2, database is mySQL.
Now I want to use Amazon RDS to backup this database in case the ec2 fails.
I read through the Amazon RDS user guide,it tells how to create a DB instance.
My question is:
1.what is the relation between created DB instance and my ec2 database?
2.When the DB instance "connect" to my ec2, what will happen?
The data used to send to ec2 mySQL server will be send to DB instance?
Is the database totally shifted to DB instance?So before I connect I should creare a same database in DB instance and tell ec2 send data to RDS ever since
3.If not,how the DB instance know the ec2 is down and takeover the data?
EDIT:
(Unsure)Is it that DB instance is just a place to put database.In order to use it,I need to set up database in DB instance,then connect to it by modifying database.yml file(this file tell rails server where the stored data goes).
How Is it possible to tell when the local database stops then at that time switch to DB instance?
There is absolutely no relationship between your EC2 MySQL DB and the RDS DB Instance. So what you are asking for is just not possible.
A better approach I would say is to have only RDS (No need to have MySQL running locally on EC2 instance). RDS takes snapshots regularly. Also, RDS is a managed service, so most of the MySQL administration tasks are handled by AWS and you don't have to worry. And you can rely on RDS snapshots from Backup perspective.

Where can I find AWS RDS snapshot hostname?

I have a MySQL instance running on RDS and I have created a snapshot and I read I can connect to snapshot. But I can't find snapshot specific hostname there on RDS management console. Can I really connect to AWS RDS snapshot using mysql client like I connect to instances?
There was an implication in the linked answer that you would need to restore the snapshot to an RDS instance. A snapshot isn't a live MySQL database -- you can't connect to it and use that state until you restore a new RDS instance from that snapshot. Here's how snapshots are defined in the documentation, if it helps:
DB snapshots are user-initiated and enable you to back up your DB
instance in a known state as frequently as you wish, and then restore
to that specific state at any time. DB snapshots can be created with
the Amazon RDS console or the CreateDBSnapshot action in the Amazon
RDS API. DB snapshots are kept until you explicitly delete them with
the Amazon RDS console or the DeleteDBSnapshot action in the Amazon
RDS API.
You can restore from a snapshot from the AWS console, or programmatically through the:
CLI: restore-db-instance-from-db-snapshot
API: RestoreDBInstanceFromDBSnapshot