检查 PostgreSQL 中的角色是否设置了密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23641823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Check if a role in PostgreSQL has a password set
提问by aef
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.
我想知道如何验证角色(用户只是一种特定类型的角色)是否在 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):
我尝试了该命令\dg+
,\du+
但他们没有向您显示任何与密码相关的信息。我还使用了以下查询,但由于它的冷漠(我很确定在这种情况下 postgresql 用户没有设置密码),它也无济于事:
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 | ******** | |
回答by jdiver
Passwords are stored in pg_shadow
密码存储在pg_shadow 中
In documentation:
在文档中:
Password (possibly encrypted); null if none. See pg_authid for details of how encrypted passwords are stored.
密码(可能是加密的);如果没有,则为 null。有关如何存储加密密码的详细信息,请参阅 pg_authid。
So you should select * from pg_shadow;
所以你应该 select * from pg_shadow;
You should also check pg_authidtable.
您还应该检查pg_authid表。