ERROR: permission denied for relation tablename on Postgres while trying a SELECT as a readonly user

前端 未结 5 1835
情话喂你
情话喂你 2020-11-28 18:54
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;

The readonly user can connect, see the tables but when it tries to do a simple select it g

5条回答
  •  [愿得一人]
    2020-11-28 19:08

    This worked for me:

    Check the current role you are logged into by using: SELECT CURRENT_USER, SESSION_USER;

    Note: It must match with Owner of the schema.

    Schema | Name | Type | Owner
    --------+--------+-------+----------

    If the owner is different, then give all the grants to the current user role from the admin role by :

    GRANT 'ROLE_OWNER' to 'CURRENT ROLENAME';

    Then try to execute the query, it will give the output as it has access to all the relations now.

提交回复
热议问题