fastread homefastrread library fastread menu

PostgreSQL : Change a user password

Tutorial by:      Date: 2016-04-19 23:29:32

❰ Previous Next ❱

This PostgreSQL tutorial explains how to change a user's password in PostgreSQL with syntax and examples.

Description

The ALTER USER statement is used to change a user's password in the PostgreSQL database.

Syntax

The syntax for changing a password using the ALTER USER statement in PostgreSQL is:

ALTER USER user_name

  WITH [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'new_password'

| VALID UNTIL 'expiration';

Parameters or Arguments

user_name

The user whose password you wish to change.

new_password

The new password to assign to the user.

expiration

The date/time value when the password will expire. If you never want the password to expire, you set expiration to 'infinity'.

Example

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 fastread.aitechtonic with the password fantastic, you would run the following ALTER USER statement in PostgreSQL:

ALTER USER fastread.aitechtonic

  WITH PASSWORD 'fantastic';

If you wanted to set the password for the user fastread.aitechtonic to expire on January 1, 2015, you would use the ALTER USER statement as follows:

ALTER USER fastread.aitechtonic

  VALID UNTIL 'Jan 1, 2015';

If you wanted the password for the user fastread.aitechtonic to never expire, you would use the ALTER USER statement as follows:

ALTER USER fastread.aitechtonic

  VALID UNTIL 'infinity';

 

❰ Previous Next ❱


PostgreSQL

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website