我们使用 Azure Database for PostgreSQL 灵活服务器。我的要求是创建管理员用户,该用户应该能够对整个数据库中任何模式中的任何表进行任何操作(DDL/Alter 等),无论哪个用户创建了该表、函数、过程或序列等。
我尝试根据 Azure Docs 创建管理员用户:
Your server admin user is a member of the azure_pg_admin role. However, the server admin account is not part of the azure_superuser role. Since this service is a managed PaaS service, only Microsoft is part of the super user role.
CREATE USER <new_user> CREATEDB CREATEROLE PASSWORD '<StrongPassword!>';
GRANT azure_pg_admin TO <new_user>;
我创建了一个名为 test_admin
的用户,并按照文档所述授予其 azure_pg_admin
角色。我使用另一个普通用户登录并创建了一个表,但 test_admin
无法查询它,并收到此错误:
permission denied for table
即使test_admin
有azure_pg_admin
。
谁能帮我解决这个问题吗?
最佳答案
根据 MS Document
The admin user is the highest privilege user you have on the server. It belongs to the role azure_pg_admin. This role does not have full superuser permissions.
据我所知,它不具备对所有架构中的所有表执行所有操作所需的所有权限,而 azure_pg_admin
角色无法使用该权限。要查询每个模式或平均数据库中的任何表,您需要显式提供它。它是 Azure Database for PostgreSQL 中的内置角色,提供管理服务器的管理权限。
授予权限的psql命令:
--grant permission on particular database level permissions.
GRANT ALL PRIVILEGES ON DATABASE DB_name TO User_name;
--grant permission on all tables of schema.
GRANT SELECT ON ALL TABLES IN SCHEMA Schema_name TO User_name;
关于postgresql - Azure PostgreSQL - 如何创建管理员用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76272100/