Password_encryption = On
postgres=# create user user1 with encrypted password ' user1 ';
CREATE ROLE
postgres=# Create user user2 with unencrypted password ' user2 ';
CREATE ROLE
postgres=# Create user User3 with password ' user3 ';
CREATE ROLE
postgres=# select usename,passwd from Pg_shadow;
Usename | passwd
----------+-------------------------------------
Postgres |
User1 | Md57d1b5a4329b6478e976508ab9a49ee3d
User2 | User2
User3 | Md516bd93afc66e593f3aeedecdf1201ee6
(4 rows)
postgres=# select Rolname,rolpassword from Pg_authid;
Rolname | Rolpassword
----------+-------------------------------------
Postgres |
User1 | Md57d1b5a4329b6478e976508ab9a49ee3d
User2 | User2
User3 | Md516bd93afc66e593f3aeedecdf1201ee6
(4 rows)
The following two views show an encrypted password
postgres=# select usename,passwd from Pg_user;
Usename | passwd
----------+----------
Postgres | ********
User1 | ********
User2 | ********
User3 | ********
(4 rows)
postgres=# select Rolname,rolpassword from Pg_roles;
Rolname | Rolpassword
----------+-------------
Postgres | ********
User1 | ********
User2 | ********
User3 | ********
(4 rows)
Password_encryption = Off
postgres=# select usename,passwd from Pg_shadow;
Usename | passwd
----------+-------------------------------------
Postgres |
User1 | Md57d1b5a4329b6478e976508ab9a49ee3d
User2 | User2
User3 | Md516bd93afc66e593f3aeedecdf1201ee6
(4 rows)
postgres=# select Rolname,rolpassword from Pg_authid;
Rolname | Rolpassword
----------+-------------------------------------
Postgres |
User1 | Md57d1b5a4329b6478e976508ab9a49ee3d
User2 | User2
User3 | Md516bd93afc66e593f3aeedecdf1201ee6
(4 rows)
postgres=# select usename,passwd from Pg_user;
Usename | passwd
----------+----------
Postgres | ********
User1 | ********
User2 | ********
User3 | ********
(4 rows)
postgres=# Select Rolname,rolpassword from Pg_roles;
Rolname | Rolpassword
----------+-------------
Postgres | ********
User1 | ********
User2 | ********< br> User3 |
(4 rows)
postgres=# create user user4 with password ' user4 ';
Create ROLE
postgres=# create user User5 with encrypted password ' user5 ';
Create ROLE
postgres=# create user User6 with unencrypted password ' user6 ';
CREATE ROLE
postgres=# select usename,passwd from Pg_shadow;
Usename | passwd
----------+------------------- ------------------
Postgres |
User1 | Md57d1b5a4329b6478e976508ab9a49ee3d
User2 | user2
User3 | md516bd93afc66e593f3aeedecdf1201ee6
User4 | User4
User5 | md51dc34834df4da4804236eb250118fb41
User6 | User6
(7 rows)
postgres=# select Rolname,rolpassword from Pg_authid;
Rolname | Rolpassword
----------+-------------------------------------
Postgres |
User1 | Md57d1b5a4329b6478e976508ab9a49ee3d
User2 | User2
User3 | Md516bd93afc66e593f3aeedecdf1201ee6
User4 | User4
User5 | Md51dc34834df4da4804236eb250118fb41
User6 | User6
(7 rows)
postgres=# select usename,passwd from Pg_user;
Usename | passwd
----------+----------
Postgres | ********
User1 | ********
User2 | ********
User3 | ********
User4 | ********
User5 | ********
User6 | ********
(7 rows)
postgres=# select Rolname,rolpassword from Pg_roles;
Rolname | Rolpassword
----------+-------------
Postgres | ********
User1 | ********
User2 | ********
User3 | ********
User4 | ********
User5 | ********
User6 | ********
(7 rows)
postgres=# alter user postgres with password ' postgres ';
ALTER ROLE
postgres=# select usename,passwd from Pg_shadow;
Usename | passwd
----------+-------------------------------------
User1 | Md57d1b5a4329b6478e976508ab9a49ee3d
User2 | User2
User3 | Md516bd93afc66e593f3aeedecdf1201ee6
User4 | User4
User5 | Md51dc34834df4da4804236eb250118fb41
User6 | User6
Postgres | Postgres
(7 rows)
postgres=# alter user user1 with password ' pguser1 ';
ALTER ROLE
postgres=# select usename,passwd from Pg_shadow;
Usename | passwd
----------+-------------------------------------
User2 | User2
User3 | Md516bd93afc66e593f3aeedecdf1201ee6
User4 | User4
User5 | Md51dc34834df4da4804236eb250118fb41
User6 | User6
Postgres | Postgres
User1 | Pguser1
(7 rows)
Views of PostgreSQL user password and encrypted or unencrypted