Take the 2-minute tour ×
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.

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 stackoverflow.com Jun 20 at 22:04

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

1 Answer 1

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

 
discard

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.