从转储文件创建的数据库的 Postgres 权限

roh*_*wal 1 postgresql

我想创建一个数据库ABC。我想使用转储文件(例如 ABC_DUMP)将数据加载到 ABC 中。我希望用户 ABC_USER 拥有数据库 ABC 的所有访问权限,包括创建、选择、更改、更新。我使用以下命令登录 psql:

postgres@ubuntu:~$ psql
postgres=# CREATE DATABASE ABC;
postgres=# GRANT ALL PRIVELEGES ON DATABASE ABC TO ABC_USER;
postgres=# \q
postgres@ubuntu:~$ psql -h localhost ABC -U ABC_USER < ABC_DUMP
Password for user ABC_USER xxxxxx
CREATE FUNCTION
ERROR:  must be member of role "postgres"
CREATE FUNCTION
ERROR:  must be member of role "postgres"
CREATE FUNCTION
ERROR:  must be member of role "postgres"
CREATE FUNCTION
ERROR:  must be member of role "postgres"
CREATE AGGREGATE
ERROR:  must be member of role "postgres"
SET
SET
CREATE TABLE
ERROR:  must be member of role "postgres"
CREATE TABLE
ERROR:  must be member of role "postgres"
CREATE SEQUENCE
ERROR:  must be member of role "postgres"
ALTER SEQUENCE
CREATE SEQUENCE
ERROR:  must be member of role "postgres"
...
Run Code Online (Sandbox Code Playgroud)

我怎样才能避免这些错误?我已尝试将公共模式的所有权限授予用户 ABC_USER 但仍然收到错误。

角色名称:ABC_USER,角色属性列表 - 创建数据库、创建角色角色
名称:Postgres,角色属性列表 - 超级用户、创建角色、创建数据库、复制、绕过 RLS

使用 postgres 版本 9.5.6

roh*_*wal 5

问题出在转储文件上。它已设置所有者,因此我无法使用用户 ABC_USER 转储数据。我创建了另一个转储文件,但这次使用--no-owner标志并使用该转储文件并且它起作用了。

pg_dump ABC --no-owner > ABC_DUMP
Run Code Online (Sandbox Code Playgroud)