-1

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!

1

1 Answer 1

1

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 😊

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.