Frage

I have DB owned by postgres, and I need to dump it, but postgres user does not have rights to write. So it boils down to login to DB as postgres but under different user in OS. How can I do that? I tried -U postgres but get an error even without password prompt. Basically I seek for `mysql -u root -p' in Postgres.

War es hilfreich?

Lösung

Dump to the standard output, and have another OS user write to the file.

Assuming you're root:

# (su postgres -c 'pg_dump -U postgres dbname') > /path/to/backup.sql

The resulting file will created and written by root.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top