- Newest
- Most votes
- Most comments
You should connect to the database with the master username and password that you setup when creating the. RDS instance. If you need assistance, see this part of the documentation: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html
psql \
--host=<DB instance endpoint> \
--port=<port> \
--username=<master username> \
--password \
--dbname=<database name>
If you no longer have the master credentials, you can follow the following process to reset them.
How do I reset the admin user password for my Amazon RDS DB instance?
https://repost.aws/knowledge-center/reset-master-user-password-rds
Well, Thank you everyone for answers, but it seems that AWS does not allow to log in as superuser on RDS with Postgres : https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html
As another example, you don't have access to the PostgreSQL superuser account. On RDS for PostgreSQL, the rds_superuser role is the most highly privileged role, and it's granted to postgres at set up time. Whether you're familiar with using PostgreSQL on-premises or completely new to RDS for PostgreSQL, we recommend that you understand the rds_superuser role, and how to work with roles, users, groups, and permissions. For more information, see Understanding PostgreSQL roles and permissions.
So, that might explain why it's impossible for me to log in as superuser.
If someone is trying to install Postgresql on EC2 to access to psql command because the AWS RDS Instance is on VPC with no internet access, here is the way :
- Search packages:
sudo yum search postgresql
- You need to install postgresql-XX-server:
yum install postgresql15-server.x86_64
- We want to be able to use psql, so we need to initialize the server:
sudo su - postgres
- We'll be the postgres user, then we need to specify:
postgresql-setup --initdb
- You'll then need to start the postgres service, which you can do with the ec2-user, by typing:
exit
- Then start the postgres service:
sudo systemctl start postgresql
- You can check with:
systemctl
- Then reconnect to the postgres user:
sudo su - postgres
- Then type the command to access the database:
psql --host=database_endpoint --port=database_post(5432 by default with postgres) --username=user_name --password --dbname=database_name
For me, it's impossible to log as superuser (rdsadmin) :
psql: error: connection to server at "database_endpoint" (ip_adress), port 5432 failed: FATAL: pg_hba.conf rejects connection for host "ip_adress", user "rdsadmin", database "original_db", SSL encryption
connection to server at "database_endpoint" (ip_adress), port 5432 failed: FATAL: pg_hba.conf rejects connection for host "ip_adress", user "rdsadmin", database "original_db", no encryption
I can connect with postgres but not rdsadmin. Inbound rules are OK for the security group (0.0.0.0/0), and it's not possible to edit pg_hba.conf with AWS RDS...
Hi iBehr and Pouleto I am wondering if you could help with this problem. It's different but perhaps you have some recommendations?! Appreciate your help :) https://repost.aws/questions/QUKO7vMLXfTb-AqqeKMImJKg/abstract-error-when-converting-rds-mysql-5-7-44-to-mysql-8
Hello iBehr and Govind Kumar,
Thank you for your feedback, unfortunatly i'm still not able to connect :
psql: error: could not translate host name "**my_rds_endpoint**" to address: Unknown host
This may be because my RDS instance is not publicly accessible.
I've looked into using this command with an SSH tunnel (with .PEM identification file) but haven't found a solution.
I also looked into installing Postgres on my EC2 instance which is in the same VPC as my RDS instance in order to use this command within the VPC, but it doesn't seem possible: ¨
[ec2-user@**ip_adress**]$ sudo yum install -y postgresql
Last metadata expiration check: 14:50:06 ago on Sun Jun 25 04:40:12 2023.
No match for argument: postgresql
I can't find a solution to my problem, even when I type this command in my CLI pgadmin, I get an error :
original_db-> \c rdsadmin
connection to server on "**ip_adress**", port 53562 failed: FATAL: pg_hba.conf rejects connection for host "**ip_adress**", user "postgres", database "rdsadmin", SSL encryption
connection to server on "**ip_adress**", port 53562 failed: FATAL: pg_hba.conf rejects connection for host "**ip_adress**", user "postgres", database "rdsadmin", no encryption
Previous connection retained
Any idea?
Even when logged in with master admin, I am getting the error that is
SQL Error [42501]: ERROR: permission denied to drop objects
I am not sure, how to login with superuser or how to grant superuser privilege to master admin.
Relevant content
- asked a year ago
- asked 2 years ago
- asked 2 years ago
- How do I resolve the storage full issue on my RDS for MySQL instance or my RDS for MariaDB instance?AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
Yes, you should definitely run it from an instance in the VPC and ensure the RDS security group allows the connection from the client.
Make sure the instance where you are installing the Postgres client has internet access. Either a public subnet with a default route to an Internet Gateway (IGW) or a private subnet with a default route to a NAT Gateway in a public subnet.
Thank you, but unfortunatly i'm not able to install Postgres on the EC2 instance and I don't know why actually...
I did a search on what is available :
Saw this in the available packages : postgresql15.x86_64 : PostgreSQL client programs, so I installed it :
But still, unable to do anything in the EC2 instance :
Tired psql :
Tired to launch the server :
Tired to restart the server :
Do you know what can be wrong here?
Postgresql is the server process -- you don't need to run that on the client.
psql
is the client process used to connect to the database. When you run it without arguments it tries to connect to a local database via socket. Run it with the specified arguments to connect to a remote database (RDS).