Holasmabre
Holasmabre

Reputation: 92

How to remotely connect to MySQL database which is in Private EC2 instance to Visual Studio in localhost

I have created 2 EC2 instance one is public which has public IP and private IP and other one is private instance which has only private IP. Only public instance can access private instance and private instance contains MYSQL database. Public instance contain webserver which I publish from local pc. I want to know how to access to database which is in my private instance to my ASP.net project so I can establish SQL connection

Upvotes: 2

Views: 1258

Answers (2)

Marcin
Marcin

Reputation: 238497

The common way to access a private instance, rds or any other resource in a VPC from your local workstation is through ssh tunnel.

So basically, you would establish ssh tunnel to a public instance, which would then forward connections to the private instance with mysql. Having the tunnel, you would access your database using localhost on your local workstation.

There is a number of tutorials on how to do it. Examples are:

Upvotes: 2

Caius Jard
Caius Jard

Reputation: 74660

You could run a port redirector software on the publicly accessible instance, to redirect traffic to the private instance, then open up the public instance's firewall to accept traffic from your IP only, to the port redirector port

Or, use something like ngrok on the private instance to funnel traffic through their proxies and make it like MySQL is running on your machine

Or install MySQL studio software on the public instance and access it via RDP

But for all the messing around it is, I'd just give the private instance a public ip address, lock it down to being accessible to your IP only and use it directly

Upvotes: 1

Related Questions