pgsql:connection failed connection to server at “1“, port 5432 failed “postgres“ P

psql: 错误: 连接到"127.0.0.1"上的服务器,端口5432失败:致命错误: 用户 “postgres” Password 认证失败

密码不对,需要重置密码

一.先确保环境变量配置正确

path中

L:mywebdatabasepgsqlpgsqlin

二.修改安装目录里的 data里的pg_hba.conf 文件

# TYPE  DATABASE        USER            ADDRESS                 METHOD

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

改成

# 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

三.ctrl + shift + Esc 找到postgresql-x64-17 重新运行服务

四.运行sql shell(psql)

4.1 连接数据库
psql -U postgres
4.2 修改密码
ALTER USER postgres PASSWORD 'new_password';

五.打开pgAdmin并输入新密码

六.把第二步的东西改回去,重启服务

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值