-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!

funKatz
  • 33
  • 1
  • 5
  • 1
    See: [Installing PostgreSQL Client v10 on AWS Amazon Linux (EC2) AMI - Stack Overflow](https://stackoverflow.com/questions/49573258/installing-postgresql-client-v10-on-aws-amazon-linux-ec2-ami) – John Rotenstein Jan 23 '22 at 22:27

1 Answers1

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

s4ros
  • 24
  • 3