I want to map Linux's root user to Postgres user, like if I enter psql in root user it should go the PostgreSQL cli without asking any authentication.

I tried to add an entry in pg_ident.conf and make the necessary changes in pg_hba.conf, but it didn't work.

psql: FATAL:  role "root" does not exist

Postgresql Version 9.6

root                 root            postgres

local   all     all                     peer map=root 
host    all     all    ident map=root 

Any suggestions to achieve this?

I need to map multiple Linux users. The above one is for who all are using root user.

  • Could you show us how did you map these users? – JSapkota May 3 '17 at 4:38
  • Updated the question – Bhuvanesh May 3 '17 at 9:24

Finally, it comes to end.

The problem is I need to replace the below line.

local   all             postgres                                peer


local   all             postgres                                peer  map=root

Thats it, no more changes.

Got this from:

This link


You need to reload the configuration, with pg_ctl reload or kill -HUP to the postmaster process. (You did not mention it in your question so I suppose you forgot about it.)

  • I have restarted​ the postgreql – Bhuvanesh May 3 '17 at 7:42
  • Then we need to see your entries in the .conf files. – Ho Zong May 3 '17 at 7:51
  • Updated the question – Bhuvanesh May 3 '17 at 8:30
  • I cannot do experiments now with configs, but was always using sudo -u postgres psql to access the database as superuser, supposing sudo setup is ok on your box. Being root continuously on a server is a bad habit. – Ho Zong May 3 '17 at 9:33
  • 1
    I want to map multiple linux users not only root, thats my requirement. – Bhuvanesh May 4 '17 at 13:19

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.