That command is one of the simplest and most common one around different database engines. (Excluding Db2-like Db engines, because it uses OS to validate passwords)
Alter is the command we use to change / update an attribute or object in database engines. So simply, change user’s password in PostgreSQL as:
ALTER USER user_name WITH PASSWORD 'new_password'

Of course, you need to run ALTER USER statement as a ALTER USER priviledge granted user.
But what if you want to change password with itself? I mean, you received a ticket from DevOps or Application team to change password of a user and you don’t have postgres, or any other administrative user’s credentials to access the system.
Login operating system as the user you want to change password. And use the command \password
\password username
Password command will ask you new password.

In this article we covered hot can i change a PostgreSQL user password topic.
If you have a question or any comments, please leave it below, i’ll try my best to get back to you as soon as possible.



Leave a Reply