简体   繁体   中英

Postgres ERROR: permission denied for table

I have a dump file generated by using pg_dump from a remote database. I am using the file to restore and populate a database using psql. I did not have the user and database name. I peeked into the sql file and figured out the user and database. Here are my steps: 1. psql -h <> -u <> -d ( I used the superuser here). 2. created the user as the application needs to access using this user only. 3. changed the owner of the database to the user created in step 2 using Pgadmin.

I am unable to access any tables and getting the error -- ERROR: permission denied for table

Please Help !

Thanks

It is better if you use dump and restore instead of psql for restoring the database. eg

eg suppose you have database dbname_source in remoteDB and dbname_target in localDB then you can use the below commands for dump and restore

./pg_dump -U postgres -p 5432 -h <remote_IP> -Ft dbname_source > dump_of_source.sql.tar 
./pg_restore -U postgres -h localhost -p 5432 -d dbname_target dump_of_source.sql.tar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM