pg_restore ERROR: permission denied to change default privileges
I have a pg_dump from a postgres instance that I am attempting to restore onto a cloud one (i.e. an instance where I don't have access to the postgres superuser) The dump was taken with: pg_dump -Fc --quote-all-identifiers --serializable-deferrable --no-unlogged-table-data my_database > my_database.dump I am attempting to restore it using the proxy admin user provided by the cloud provider: pg_restore -d "host=foobar.example.com port=12345 user=my_cloud_admin_user sslrootcert=/path/to/the/cert.crt sslmode=require dbname=my_database" -O -1 my_database.dump This is the error I am seeing: pg_restore: error: could not execute query: ERROR: permission denied to change default privilegesCommand was: ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT SELECT ON TABLES TO "my_database_ro"; N.B. "my_database_ro" being a user that was on the original database, and was successfully created in the new database by restoring a "pg_dumpall --globals-only" into the new database before attempting the pg_restore
Re: pg_restore ERROR: permission denied to change default privileges
Rachel Roch writes: > This is the error I am seeing: > pg_restore: error: could not execute query: ERROR: permission denied to > change default privilegesCommand was: ALTER DEFAULT PRIVILEGES FOR ROLE > "postgres" IN SCHEMA "public" GRANT SELECT ON TABLES TO "my_database_ro"; Well, you aren't going to be able to do that if you're not superuser. You could undo that ALTER in the source database and re-make the dump, or edit the dump script to remove this command, or not use pg_restore's "-1" switch and just ignore this error. regards, tom lane
Re: pg_restore ERROR: permission denied to change default privileges
On 6/13/25 11:23, Tom Lane wrote: Rachel Roch writes: This is the error I am seeing: pg_restore: error: could not execute query: ERROR: permission denied to change default privilegesCommand was: ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT SELECT ON TABLES TO "my_database_ro"; Well, you aren't going to be able to do that if you're not superuser. You could undo that ALTER in the source database and re-make the dump, or edit the dump script to remove this command, or not use To get at an editable script you can do something like: pg_restore -f my_database_txt.sql my_database.dump This will give you a plain text version of the dump that you can feed back to psql to load into remote database. If you want to do this in steps you can do: pg_restore -s-f my_database_sch_txt.sql my_database.dump to get the object(schema) definitions only and then pg_restore -a -f my_database_data_txt.sql my_database.dump to get the data definitions. pg_restore's "-1" switch and just ignore this error. regards, tom lane -- Adrian Klaver adrian.kla...@aklaver.com