python postgressql联接失败

could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

出现此错误,一是要考虑下pg_hba.conf文件中的配置

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# 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.
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust
 

第二步:看看服务中的开启没开启,今天不知为何,开启选项设成手动了,连不上,可能是360整理是调的

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在PostgreSQL中,可以通过修改`pg_hba.conf`文件来配置登录失败处理策略。`pg_hba.conf`文件用于控制客户端如何连接到PostgreSQL服务器,并且可以设置不同的安全策略。 在`pg_hba.conf`文件中,可以设置不同的认证类型、IP地址范围、用户名等参数,以控制客户端连接的权限和安全性。对于登录失败的处理策略,可以使用`auth_failures_limit`和`auth_failures_time`参数来控制。 `auth_failures_limit`参数用于设置在`auth_failures_time`时间内允许的最大认证失败次数。例如,将`auth_failures_limit`设置为3,将`auth_failures_time`设置为1分钟,表示在1分钟内,允许用户最多尝试3次认证失败。 修改`pg_hba.conf`文件后,需要重启PostgreSQL服务器才能使配置生效。 下面是一个`pg_hba.conf`文件的示例,演示了如何设置登录失败处理策略: ``` # TYPE DATABASE USER ADDRESS METHOD host all all 0.0.0.0/0 md5 host all all 127.0.0.1/32 md5 host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. host replication all 127.0.0.1/32 md5 host replication all ::1/128 md5 # Allow all users to connect if they have a valid certificate. # This is for SSL client certificates. See the documentation for # `ssl_crl_file' and `ssl_crl_directory' for how to configure the server # to check the client's certificate revocation status. hostssl all all all cert clientcert=1 # Allow users to connect if they are authenticated via GSSAPI or SSPI. # Note that this includes Kerberos password authentication in GSSAPI. # See the documentation for `krb_server_keyfile' and # `krb_srvname' for how to configure the server for Kerberos. host all all 0.0.0.0/0 gss host all all 0.0.0.0/0 sspi host all all ::1/128 gss host all all ::1/128 sspi # Example of setting auth_failure_limit and auth_failure_time host all all 0.0.0.0/0 md5 auth_failure_limit=3 auth_failure_time=1min ``` 在上述示例中,最后一行设置了`auth_failure_limit`为3,`auth_failure_time`为1分钟。当用户在1分钟内尝试登录3次失败后,服务器将会拒绝该用户的连接请求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

信息化未来

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值