Changing your password securely
If you are using password authentication, then you may wish to change your password from time to time. This can be done from any interface. pgAdmin is a good choice, but here we show to do that from psql.
How to do it…
The most basic method is to use the psql
 tool. The \password
 command will prompt you once for a new password and again to confirm. Connect to the psql
 tool and type the following:
SET password_encryption = 'scram-sha-256'; \password
Enter a new password. This causes psql
to send a SQL statement to the PostgreSQL server, which contains an already encrypted password string. An example of the SQL statement sent is as follows:
ALTER USER postgres PASSWORD 'SCRAM-SHA-256$4096:H45+UIZiJUcEXrB9SHlv5Q==$I0mc87UotsrnezRKv9Ijqn/zjWMGPVdy1zHPARAGfVs=:nSjwT9LGDmAsMo+GqbmC2X/9LMgowTQBjUQsl45gZzA=';
Make sure you use the SCRAM-SHA-256
encryption, not the older and...