In this PostgreSQL post explains how to change a user's password in PostgreSQL with syntax and examples.
The ALTER USER statement is used to change a user's password in the PostgreSQL database.
The syntax for changing a password using the ALTER USER statement in PostgreSQL is:
The user whose password you wish to change.
The new password to assign to the user.
The date/time value when the password will expire. If you never want the password to expire, you set expiration to 'infinity'.
Let's look at an example that shows how to use the ALTER USER statement in PostgreSQL to change a password.
For example, if you wanted to update the user named AODBA with the password fantastic, you would run the following ALTER USER statement in PostgreSQL:
If you wanted to set the password for the user AODBA to expire on January 1, 2015, you would use the ALTER USER statement as follows:
If you wanted the password for the user AODBA to never expire, you would use the ALTER USER statement as follows: