1、首先停止正在運作的postgre服務
2、找到資料庫data目錄下的 pg_hba.conf 檔案
3、打開編輯内容,host後邊的 md5 修改為 trust。(下列所有步驟操作完成後記得恢複原樣。)
# 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 md5
#host replication all ::1/128 md5
4、啟動服務,然後輸入下邊指令可直接進入到指令行模式
psql -U postgres
5、修改使用者 Postgres 密碼為 123456
ALTER USER Postgres WITH PASSWORD '123456';