PostgreSQL: How to change the Database User Password in Linux

In this post, I am sharing basic commands to change the PostgreSQL database user password in Linux.

I would like to share this kind commands and scripts because this is very common and day to day exercise for a Database Administrator.

In the PostgreSQL, we have also one pg_hba.conf file.
pg_hba.conf is a configuration file which is controlled Client Authentication.
This file automatically installed when the data directory is initialized.

If you want to login without password, you can put “peer” or “trust” instead of md5 in this file.

But for the security purpose, we should put md5.

Change database password using ALTER:

First login:

ALTER Command:

Change database password using \password:

First login:

Using \password:

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

Be the First to Comment!

Notify of