1

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?

migrated from stackoverflow.com Jun 20 '14 at 22:04

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

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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