Issue
I have an EC2 Amazon Linux2 running, and I want to access to RDS PostgreSQL databse from EC2. I have finished adding EC2's security group ID to RDS's security group inbound. I also successfully connected to RDS from my local PC.
I was looking for a way (or cli command) to connect to RDS from EC2 Amazon Linux. Similary way for MySQL is:
sudo yum install mysql
mysql -u {username} -p -h {hostname}
I want to do the same with PostgreSQL, but could not find how to do so. If there's a way I can follow through, please let me know.
Thanks!
Solution
why don't you use docker
for that?
The easiest and fastest way that comes into my head is to do something like that
First, install docker
$ curl -L get.docker.com | sudo bash
$ sudo usermod -a -G docker $(whoami)
... you need to logout & login!
Then run docker container
$ docker run --rm -it postgres psql -h [your_RDS_host] -U [username] -W [database_name]
And you should be fine 😊
Answered By - s4ros Answer Checked By - Mildred Charles (WPSolving Admin)