大网数据广告活动
服务器运维问答

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

· 52CE 我爱测

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…

问题原文

原帖链接 · jango · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Khaled · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。