How to solve privileges issues when restore PostgreSQL Database

前端 未结 10 1998
Happy的楠姐
Happy的楠姐 2020-12-12 16:19

I have dumped a clean, no owner backup for Postgres Database with the command

pg_dump sample_database -O -c -U

Later, when I restore the databas

10条回答
  •  我在风中等你
    2020-12-12 16:32

    Use the postgres (admin) user to dump the schema, recreate it and grant priviledges for use before you do your restore. In one command:

    sudo -u postgres psql -c "DROP SCHEMA public CASCADE;
    create SCHEMA public;
    grant usage on schema public to public;
    grant create on schema public to public;" myDBName
    

提交回复
热议问题