2

when I am trying to login to postgresql by using psql -d root -U postgres I am getting below error.

psql: FATAL:  Peer authentication failed for user "postgres"

And when typing only psql getting below error:

psql: FATAL:  no pg_hba.conf entry for host "[local]", user "root", database "root", SSL off

what I can do ? I am not able to undrstand.

Thanks in advance

James Brown
  • 36,089
  • 7
  • 43
  • 59
Rani
  • 119
  • 1
  • 2
  • 9

2 Answers2

1

You may try this: open pg_hba.conf file (/var/lib/pgsql/data/pg_hba.conf) and uncomment or add the line :

local all all trust

Then restart postgresql

# /etc/init.d/postgresql restart
Taufiq Rahman
  • 5,600
  • 2
  • 36
  • 44
0

Do you try to login with user postgres to database root while current user is root?

Your options are:

current user: root; desired user: postgres; desired database: root

in pg_hba.conf:local postgres root md5 and execute: psql -d root -U postgres and login with your password for postgres

current user: postgres; desired user: postgres; desired database: root

in pg_hba.conf: local postgres root peer and execute psql -d root

current user: root; desired user: root; desired database: root

in pg_hba.conf local root root peer and execute psql

Neither to say never to login as root at your database!

Ben H
  • 435
  • 5
  • 15