psql:FATAL:主机“”,用户“root”,数据库“root”,closuresSSL的pg_hba.conf条目

在我们的Linux服务器上,我们有PostgreSQL数据库

当我们键入 –

psql -l 

我们得到

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

我们需要在/var/lib/pgsql/data/pg_hba.conf中设置以解决这个问题?

要列出数据库,您可以执行您的命令作为postgres用户:

 $ sudo su postgres -c 'psql -l' 

如果您已经以root身份login,则可以从上述命令中删除sudo 。 用户postgres被认为是PostgreSQL数据库引擎的root用户。

您的post中显示的错误表明,没有从localhost访问postgres数据库的用户root访问权限。 因此,您可以编辑pg_hba.conf文件以包含所需的login详细信息,如login名,数据库名称和主机。 该文件是有据可查的。

对于您的情况,您可以pg_hba.conf下行添加到pg_hba.conf文件中:

 local all root peer 

保存更改后,您需要重新加载postgresql服务器。