没有主机的 pg_hba.conf 条目 [英] no pg_hba.conf entry for host

查看:29
本文介绍了没有主机的 pg_hba.conf 条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用 DBI 连接时出现以下错误

<前>DBI connect('database=chaosLRdb;host=192.168.0.1;port=5433','postgres',...)失败:致命:没有主机192.168.0.1"的 pg_hba.conf 条目,用户postgres",数据库chaosLRdb",SSL 关闭

这是我的 pg_hba.conf 文件:

# "local" 仅用于 Unix 域套接字连接本地所有所有 md5# IPv4 本地连接:托管所有所有 127.0.0.1/32 md5# IPv6 本地连接:主持所有所有::1/128 md5托管所有 postgres 127.0.0.1/32 信任托管所有 postgres 192.168.0.1/32 信任托管所有所有 192.168.0.1/32 信任托管所有所有 192.168.0.1/128 信任托管所有所有 192.168.0.1/32 md5主机chaosLRdb postgres 192.168.0.1/32 md5本地所有所有 192.168.0.1/32 信任

我的 perl 代码是

#!/usr/bin/perl-w使用 DBI;使用文件句柄;print "开始连接数据库...
";@ary = DBI->available_drivers(true);%drivers = DBI->installed_drivers();my $dbh = DBI->connect("DBI:PgPP:database=chaosLRdb;host=192.168.0.1;port=5433", "postgres", "chaos123");

我可以知道我在这里想念什么吗?

解决方案

如果你能改变这一行:

host all all 192.168.0.1/32 md5

有了这个:

host all all all md5

你可以看看这是否能解决问题.

但另一个考虑是你的 postgresql 端口(5432)对黑客的密码攻击非常开放(也许他们可以暴力破解密码).您可以将 postgresql 端口 5432 更改为33333"或其他值,这样他们就无法知道此配置.

I get following error when I try to connect using DBI

DBI connect('database=chaosLRdb;host=192.168.0.1;port=5433','postgres',...) 
failed: FATAL:  no pg_hba.conf entry for host "192.168.0.1", user "postgres", database "chaosLRdb", SSL off

Here is my pg_hba.conf file:

# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

host    all         postgres    127.0.0.1/32          trust

host    all        postgres     192.168.0.1/32        trust

host    all        all         192.168.0.1/32        trust

host    all        all         192.168.0.1/128        trust

host    all        all         192.168.0.1/32        md5

host    chaosLRdb    postgres         192.168.0.1/32      md5
local    all        all         192.168.0.1/32        trust

My perl code is

#!/usr/bin/perl-w
use DBI;
use FileHandle;

print "Start connecting to the DB...
";

@ary = DBI->available_drivers(true);
%drivers = DBI->installed_drivers();
my $dbh = DBI->connect("DBI:PgPP:database=chaosLRdb;host=192.168.0.1;port=5433", "postgres", "chaos123");

May I know what i miss here?

解决方案

If you can change this line:

host    all        all         192.168.0.1/32        md5

With this:

host    all        all         all                   md5

You can see if this solves the problem.

But another consideration is your postgresql port(5432) is very open to password attacks with hackers (maybe they can brute force the password). You can change your postgresql port 5432 to '33333' or another value, so they can't know this configuration.

这篇关于没有主机的 pg_hba.conf 条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆