从没有角色 and/or 权限的 .sql 转储文件恢复 postgres 模式?
Restore postgres schema from .sql dump file without role and/or permissions?
我在尝试从另一台服务器上创建的 .sql 转储文件恢复 postgres 数据库模式时收到以下错误:
REVOKE psql:backup.sql:158885: ERROR: role "server_name" does not exist
转储文件是使用 pg_dump -U username "server_name" -n schema_name > schema_name.sql
创建的
如何创建没有角色 and/or 权限的转储文件?
通过使用标志 --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.
防止恢复访问权限(grant/revoke 命令):
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
我在尝试从另一台服务器上创建的 .sql 转储文件恢复 postgres 数据库模式时收到以下错误:
REVOKE psql:backup.sql:158885: ERROR: role "server_name" does not exist
转储文件是使用 pg_dump -U username "server_name" -n schema_name > schema_name.sql
如何创建没有角色 and/or 权限的转储文件?
通过使用标志 --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.
防止恢复访问权限(grant/revoke 命令):
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