1
$ whomi
admin

$ pg_dump
(it works....)

$ sudo pg_dump
doesn't work. (permission denied)

$ sudo -u admin pg_dump 
still doesn't work (permission denied).

why is that?

I need to run pg_dump from the context of being the user "www-data". How can I do that?

JasonGenX
  • 522
  • 1
  • 5
  • 16

1 Answers1

1

Your system user admin has a matching PostgreSQL account called admin, and the pg_hba.conf rules allow it to authenticate. If you want PostgreSQL to also support users root or www-data, create them in PostgreSQL, and set up equivalent rules for them, too.

Josip Rodin
  • 1,695
  • 13
  • 18
  • where is the "admin" account in postgres? I don't see it. when I do "\du" there is no admin on the list. – JasonGenX Mar 19 '16 at 16:30
  • There is no such account by default, you can create it the normal way users are created in PostgreSQL. (Typically the `postgres` account is the administrative account.) – Josip Rodin Mar 19 '16 at 19:38