1

on our Linux server we have PostgreSQL DB

when we type -

psql -l 

we get

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

what we need to set in the /var/lib/pgsql/data/pg_hba.conf in order to fix this?

1 Answer 1

4

To list the databases, you can execute your command as postgres user:

$ sudo su postgres -c 'psql -l' 

If you are already logged in as root, you can remove sudo from the above command. User postgres is considered as root user for PostgreSQL database engine.

The error shown in your post indicates that there is no access for user root from localhost to access postgres database. So, you can edit pg_hba.conf file to include the desired login details like login name, DB name, and host. The file is well documented.

For your case, you can add the following line to pg_hba.conf file:

local all root peer 

You need to reload your postgresql server after saving the changes.

2
  • can you please advice how to edit the file pg_hba.conf to solve this? Commented Nov 7, 2017 at 9:46
  • @jango: Updated my answer to allow access for root user. Commented Nov 7, 2017 at 10:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.