Why does the OS user has to be same as the database user while connecting to PostgreSQL using md5 authentication? -


i have configured md5 authentication user foo putting following in pg_hba.conf:

# type    database    user    address    method local             foo                md5 

when try connect (using psql) linux user foo, psql asks password , connection successful. however, if run psql other linux user, receive following error:

psql: fatal:  password authentication failed user "foo" 

what reason behavior? under impression necessary if use peer or ident authentication methods.

edit: using command psql -u foo -w connect. when prefix command sudo -u foo works; when don't gives error mentioned above. sorry not mentioning while posting original question!

edit 2:

here un-commented lines pg_hba.conf in order:

# type    database    user        address        method local             postgres                   peer local             foo                        md5 local                     127.0.0.1/32   md5 local                     ::1/128        md5 

if don't specify database try connect database same name linux user. if logged bar , do:

psql -u foo -w 

it try log bar database foo user. connect foo database bar loggin do:

psql -u foo -w foo 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -