欢迎光临!
若无相欠,怎会相见

PostgreSQL: 解决 FATAL: no pg_hba.conf entry for host “*”, user “*”, database “postgres”

序言

同上一篇文章, 在 NAS 上安装了矿神的 PostgreSQL 套件, 有了 MariaDB 和 PostgreSQL 之后, 足够了。

可能后面还会安装 NoSQL 数据库。

也是遇到了无法连接的情况, 这里记录一下, 方便以后使用。

正文

解决这个问题, 需要先找到 pg_hba.conf 文件, 这个文件里面有设置权限。

矿神的这个套件安装的目录如下:

/volume1/@appstore/postgresql

而 pg_hba.conf 文件则是在数据目录里面, 如下:

/volume1/@appstore/postgresql/share/data

/volume1/@appstore/postgresql/share/data/pg_hba.conf

其权限内容默认如下:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

然后可以添加一条规则 : host all pgadmin 192.168.31.33/24        md5

完整的如下:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust
host    all             pgadmin         <client ip>/32          md5

保存后重新启动 PostgreSQL 数据库。

结语

上方操作经本人实操, 可以解决问题。

如有错误, 敬请指出, 感谢指正!  —  2025-01-04  22:38:47

赞(0) 打赏
转载请注明:飘零博客 » PostgreSQL: 解决 FATAL: no pg_hba.conf entry for host “*”, user “*”, database “postgres”
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

欢迎光临