Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a role in PostgreSQL has a password set

I wonder how I can verify whether or not a role (users are just a specific kind of role) has a password set in PostgreSQL 9.1.

I tried the command \dg+ and \du+ but they don't show you anything password related. I also used the following query, but it doesn't help either because of its indifference (I'm quite sure that the postgresql user has no password set in this case):

SELECT * FROM pg_user;   usename  | usesysid | usecreatedb | usesuper | usecatupd | userepl |  passwd  | valuntil | useconfig  ----------+----------+-------------+----------+-----------+---------+----------+----------+-----------  postgres |       10 | t           | t        | t         | t       | ******** |          |   aef      |    16201 | t           | t        | t         | t       | ******** |          |  
like image 306
aef Avatar asked May 13 '14 21:05

aef


People also ask

How do I check postgres user privileges?

Check PostgreSQL User Privileges Once you're connected to your database cluster, you can use the \du command to list users that currently exist and see their roles.

Does postgres user have password?

For most systems, the default Postgres user is postgres and a password is not required for authentication. Thus, to add a password, we must first login and connect as the postgres user.

What is set role in PostgreSQL?

SET ROLE NONE sets the current user identifier to the current session user identifier, as returned by session_user . RESET ROLE sets the current user identifier to the connection-time setting specified by the command-line options, ALTER ROLE , or ALTER DATABASE , if any such settings exist.


1 Answers

Passwords are stored in pg_shadow

In documentation:

Password (possibly encrypted); null if none. See pg_authid for details of how encrypted passwords are stored.

So you should select * from pg_shadow;

You should also check pg_authid table.

like image 52
jdiver Avatar answered Oct 03 '22 21:10

jdiver