PostgreSQL
Version: 15.2 | OS: Ubuntu 22.04
Overview
PostgreSQL is a powerful, open-source object-relational database system known for reliability, robust feature support, and high performance.
Included Software
- PostgreSQL - 15.2
Firewall & Access
Port | Service | Purpose |
---|---|---|
22 | SSH (rate limited) | Secure server access |
5432 | PostgreSQL | Database access |
Initial Deployment
During the deployment process:
- PostgreSQL is installed and configured
- You will be logged out with the message:
Please wait until the installation is completed....
Connection to $IPADDRESS closed.
Wait at least 2 minutes before logging back in.
Accessing the Instance
- Login to your instance:
ssh ubuntu@$IPADDRESS
- Switch to root:
sudo su -
Accessing PostgreSQL
- The PostgreSQL superuser password is stored at:
/root/.postgresql_passwords
- Login as postgres user:
sudo -u postgres psql
Enable Remote Access
- Edit the
postgresql.conf
file:
nano /etc/postgresql/15/main/postgresql.conf
Uncomment and update the following line:
listen_addresses = '*'
- Edit the
pg_hba.conf
file:
nano /etc/postgresql/15/main/pg_hba.conf
Update this line to allow connections from any IP:
host all all 0.0.0.0/0 scram-sha-256
- Restart PostgreSQL:
systemctl restart postgresql
- Allow port 5432 through the firewall.
Connect Remotely
psql -h $IPADDRESS -U postgres
Replace
$IPADDRESS
with your PostgreSQL server's public IP.