【问题标题】:Postgres - grant permission to an existing user in a role groupPostgres - 向角色组中的现有用户授予权限
【发布时间】:2021-09-23 17:55:33
【问题描述】:

我正在尝试向角色组中的用户授予权限,我执行的步骤在哪里:

  1. 创建用户:myuser
  2. 创建角色组:只读
  3. grant read_only to myuser
  4. grant select on all tables in schema public to read_only
  5. alter default priviliges in schema public grant select on tables to read_only

完成上述所有步骤后,当我使用myuser 查询表时,我得到了“权限被拒绝”。我在这里错过了什么?

【问题讨论】:

  • 您仅更改了将在该架构中创建的新表的默认权限,您尚未对现有表授予任何授权
  • @Bergi 是的,实际上我在第 4 步中已经完成了该步骤,但仍然无法查询表。

标签: postgresql user-roles


【解决方案1】:

更改默认权限只会影响新表。您需要通过发出以下命令来授予对所有现有表的权限,以便您拥有权限。

GRANT SELECT ON ALL TABLES IN SCHEMA public TO read_only;

【讨论】:

  • 我在 'alterprivilege' 语句之前有这一步 (#4),但仍然无法查询表。
猜你喜欢
  • 2019-04-13
  • 2019-05-16
  • 1970-01-01
  • 2018-10-11
  • 2020-04-28
  • 1970-01-01
  • 1970-01-01
  • 2017-01-28
  • 2018-04-09
相关资源
最近更新 更多