Unable to restore psql database from pg_dump with a different username

后端 未结 3 1160
情话喂你
情话喂你 2021-01-18 08:00

I need to dump a postgres database from computer1 with postgres username1 and then restore it on computer2 with postgres username2. I keep running into the error that looks

3条回答
  •  生来不讨喜
    2021-01-18 08:42

    If you are using pgAdmin then you can either remove the checkbox in DumpOptions #2 with Owner and otherwise remove the privilege like --no-privileges and remove ownership like --no-password in the dump query like
    /usr/bin/pg_dump --host localhost --port 5432 --username "postgres" --no-password --format custom --no-privileges --no-tablespaces --verbose --file "as" "databasename". Also if you have constraints on the table then disable triggers also while creating the dump.

    If you cannot create another backup of the database then the alternate way is to replicate the owner and roles of the dumped database to the new database. If you don't do that then you will get an error saying 'ACL does not exist' (not sure as faced it long back)

提交回复
热议问题