Update Your PostgreSQL Password in Linux
PostgreSQL supports many client authentication methods, but in this case we’re only going to concern ourselves with two: password and md5.

Before Getting Started
- These instructions are intended specifically for changing a password in PostgreSQL.
- I’ll be working from a Liquid Web Core Managed CentOS 7 server, and I’ll be logged in as root.
- PostgreSQL is installed per our tutorial on: How to Install and Connect to PostgreSQL on CentOS 7.
Step #1: Switch to the PostgreSQL User: postgres
If you’re working from a default PostgreSQL installation, then PostgreSQL will be configured with the user postgres.
Since we’re logged in as root, and we’re assuming that root doesn’t have a user for PostgreSQL, switch to the default PostgreSQL user: postgres.
su - postgres
… then attempt a connection to PostgreSQL.
psql
… enter your password at the prompt.
Password:
… the correct, valid response will be similar to the following.
psql (9.3.9)
Type "help" for help.
postgres=#
Step #2: Add/Change the PostgreSQL Password for the User: postgres
Use the following command to change the PostgreSQL password for your current user, which is now postgres.
\password
Enter your new password, and then enter it again to confirm it.
Enter new password:
Enter it again:
Now quit the PostgreSQL interface.
\q
Bonus Information!
You can do all of step one in exactly one command.
su -c "psql" - postgres
Related Articles:

About the Author: Justin Palmer
Justin Palmer is a professional application developer with Liquid Web
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
Best authentication practices for email senders
Read Article2024 cPanel and Plesk pricing breakdown
Read ArticleCentOS Linux 7 EOL — everything you need to know
Read ArticleHow to install Node.js on Linux (AlmaLinux)
Read ArticleUpgrading or installing PHP on Ubuntu — PHP 7.2 and Ubuntu 22.04
Read Article