gpt4 book ai didi

database - 从没有角色和/或权限的 .sql 转储文件恢复 postgres 架构?

转载 作者:搜寻专家 更新时间:2023-10-30 20:24:28 24 4
gpt4 key购买 nike

尝试从另一台服务器上创建的 .sql 转储文件恢复 postgres 数据库架构时收到以下错误:

REVOKE psql:backup.sql:158885: 错误:角色“server_name”不存在

转储文件是使用 pg_dump -U username "server_name"-n schema_name > schema_name.sql 创建的

如何创建没有角色和/或权限的转储文件?

最佳答案

通过使用标志 --no-owner--no-acl

Do not output commands to set ownership of objects to match the original database. By default, pg_restore issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created schema elements. These statements will fail unless the initial connection to the database is made by a superuser (or the same user that owns all of the objects in the script). With -O, any user name can be used for the initial connection, and this user will own all the created objects.

防止恢复访问权限(授予/撤销命令):

pg_dump --no-owner --no-acl -U username "server_name" -n schema > schema.sql

https://www.postgresql.org/docs/9.2/static/app-pgrestore.html

关于database - 从没有角色和/或权限的 .sql 转储文件恢复 postgres 架构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43646417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com