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. It's 100% free, no registration required.

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 was exporting a database using pg_dump command when I realized that the owner of the database had to be changed. So I change it, and make extra sure that the newuser is correct. Then try the command again:

pg_dump -h localhost -U postgres database_name -f mydb.dump

But this didn't work. The output file still identified the owner as the olduser. Why could this be happening? How can I make sure this doesn't happen?

share|improve this question

migrated from Jun 20 '14 at 22:04

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

up vote 3 down vote accepted

The way you are invoking pg_dump (without -C), the database metadata is not dumped at all.

Use this:

pg_dump -h localhost -U postgres database_name -C -f mydb.dump

This will add CREATE DATABASE and ALTER DATABASE ... OWNER TO to your dump.

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.