pgsql:connection failed: connection to server at “::1“, port 5432 failed: : û “postgres“ P(修改密碼)
psql: 錯(cuò)誤: 連接到"127.0.0.1"上的服務(wù)器,端口5432失敗:致命錯(cuò)誤: 用戶 "postgres" Password 認(rèn)證失敗
密碼不對(duì),需要重置密碼
一.先確保環(huán)境變量配置正確
path中
C:\Program Files\PostgreSQL\17\bin
二.修改安裝目錄里的 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 重新運(yùn)行服務(wù)
四.運(yùn)行sql shell(psql)
4.1 連接數(shù)據(jù)庫
psql -U postgres
AI寫代碼
4.2 修改密碼
ALTER USER postgres PASSWORD 'new_password';
AI寫代碼
五.打開pgAdmin并輸入新密碼
六.把第二步的東西改回去,重啟服務(wù)
————————————————
版權(quán)聲明:本文為博主原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接和本聲明。
原文鏈接:https://blog.csdn.net/qq_53479087/article/details/143277503

浙公網(wǎng)安備 33010602011771號(hào)