Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have just installed postgres 9.1.6 on a local Ubuntu server. Now I'm trying to restore a database dump from a database on Heroku. The local database is setup like this:

sudo -u postgres psql -c "create user app_user with password 'pass';"
sudo -u postgres psql -c "create database app_production owner app_user;"

Now, when I try to restore the the dump I use the following command:

pg_restore --verbose --schema=public --no-acl --no-owner --jobs=8 --exit-on-error --username=app_user --dbname=app_production /tmp/app_production.dump

Now in psql with \l to see ownerships I get the following:

                                         List of databases
          Name    |   Owner   | Encoding |   Collate   |    Ctype    |   Access privileges  
 app_production   | postgres  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres         | postgres  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0        | postgres  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
                  |           |          |             |             | postgres=CTc/postgres
 template1        | postgres  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
                  |           |          |             |             | postgres=CTc/postgres

As you can see, the ownership of app_production database has now turned from app_user to postgres. I would have expected the owner of the app_production database to still be app_user, so what am I doing wrong?

BTW, The --schema=public was added, because I was getting a weird error:

"Could not execute query: ERROR: must be owner of extension plpgsql"

Another thing is, that the owner of the dump is the user that the database was having on heroku, which would be something like 'jebf473b73bv73v749b7'

share|improve this question

migrated from Oct 26 '12 at 1:49

This question came from our site for professional and enthusiast programmers.

You may remove the --dbname option. This will output a SQL script containing all the restore commands instead of actually restoring. Then you can look near the beginning of that output for any ALTER DATABASE command. – Daniel Vérité Oct 29 '12 at 16:20
up vote 0 down vote accepted

If you want to create the plpgsql extension I believe you have to be Superuser. My recommendation is to make app_user temporarily a superuser and then revert this. Superusers also are treated as owners of everything.


run the restore, then when you are done


This should avoid any other permissions issues but still leave you with the permissions you want.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.