Postgres – Useful Commands
Postgres - Useful Commands
August 12, 2026
Create a file to store login and password
cd /root vi .pgpass | localhost:5432:*:postgres:password1 localhost:5433:*:postgres:password1 |
#Use Postgres sudo -p 5432 -u postgres psql #Tests the conntection sudo psql -h localhost -p 5432 -U postgres -c '\conninfo' #Resets password sudo -u postgres /usr/pgsql-16/bin/psql -p 5432 -c "ALTER ROLE postgres PASSWORD 'password1'" sudo -u postgres /usr/pgsql-17/bin/psql -p 5433 -c "ALTER ROLE postgres PASSWORD 'password1'"