postgres sql连接失败/没有PostgreSQL服务/忘记密码问题解决

postgres sql连接失败/没有PostgreSQL服务/忘记密码问题解决

1. postgres sql连接失败

报错信息: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?

在这里插入图片描述

解决:

重新启动PostgreSQL服务

在这里插入图片描述

2. 没有PostgreSQL服务问题

  1. 注册表编辑器,删除此文件夹

在这里插入图片描述

  1. 重启

  2. cd到安装目录

    F:\Program Files\PostgreSQL\13\bin
    

    输入以下命令(管理员打开cmd) 注意 -D 后面是data的路径

    pg_ctl.exe register -N "PostgreSQL" -U "NT AUTHORITY\NetworkService" -D "F:\Program Files\PostgreSQL\13\data" -w
    

3. 忘记密码

  1. 找安装目录,按下图修改红框

在这里插入图片描述

  1. 打开pgAdmin,不用输密码就可连上

如何修改密码见这篇文章:https://blog.csdn.net/u013719339/article/details/51232908

参考文章:

https://stackoverflow.com/questions/27566859/how-to-run-postgresql-as-a-service-in-windows

66859/how-to-run-postgresql-as-a-service-in-windows

https://stackoverflow.com/questions/40532399/unable-to-connect-to-server-for-postgres

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 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
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值