PostgreSQL:查看数据库连接权限
如何查看已颁发的用户GRANT CONNECT ON DATABASE
?
- \dp - 列出表/视图权限
- \dn+ - 列出架构权限
- \l+ 不列出可以访问数据库的所有用户
How do you view users that have been issued GRANT CONNECT ON DATABASE <database> TO <user>
?
- \dp - lists table/view permissions
- \dn+ - lists schema permissions
- \l+ does not list all users that can access the database
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 \l+ 命令只显示一些具有连接到数据库的权限/特权的用户,那就有点奇怪了。我自己无法在 PostgreSQL 8.4 安装(Ubuntu 10.04 LTS)上重复这一点。您使用什么版本?
无论如何,也许您可以检查保存该特定数据库的 ACL 的表,并从中推断出用户是否具有正确的权限:
如果您只想检查一个用户,您可以执行以下操作:
权限/特权如何来解释?权限应这样理解:
省略用户意味着 PUBLIC 被授予权限,即所有角色。例如,如果权限是
=Tc/postgres
,那么所有角色都可以连接并在该特定数据库中创建临时表,并且授予该权限的是postgres
用户。PostgreSQL 站点上有一个概要解释了不同的权限: https://www.postgresql.org/docs/current/ddl-priv.html#PRIVILEGE-ABBREVS-TABLE。
A bit odd if the \l+ command just displays some of the users that have permission/privilege to connect to the database. I could not repeat that myself on a PostgreSQL 8.4 installation (Ubuntu 10.04 LTS). What version are you using?
Anyway, perhaps you could check the table holding the ACL's for that particular database and from that deduce whether the user has the correct privileges or not:
If you just want to check one user you could do something like this:
How are the permissions/privileges to interpreted? The privileges are to be read like this:
Omitting user means that PUBLIC is granted the privilege, ie all roles. For example if the privilege is
=Tc/postgres
then all roles may connect and create temporary tables in that particular database and it is thepostgres
user who granted the privilege.There is a synopsis at the PostgreSQL site explaining the different privileges: https://www.postgresql.org/docs/current/ddl-priv.html#PRIVILEGE-ABBREVS-TABLE.
我正在使用 postgres 8.4 和 postgres 9.0 中的 psql,并且命令
\l
或\l+
为我提供了我可以输入的列Access Privileges
:之前我根据需要向用户授予了连接权限。
正如页面上所述 http://www.postgresql.org/docs /9.0/static/sql-grant.html,这里的
c
字母表示Connect
。I'm using psql from postgres 8.4 and postgres 9.0, and the command
\l
or\l+
gives me columnAccess Privileges
where I have entry:and earlier I gave the user the connect privilege as you wanted.
As it states on the page http://www.postgresql.org/docs/9.0/static/sql-grant.html, the
c
letter here meansConnect
.