許久不登, 倒是把默認的 postgres 用戶的密碼給忘了...
首先關閉 PostgreSQL.
我這是 Windows 上安裝的, 所以到服務 (services.msc
) 里關閉.
然后修改配置, 把 md5
改成 trust
.
到 PostgreSQL 的安裝目錄下找到 pg_hba.conf
# pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
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
然后重啟服務, 使用如下命令修改 postgres 用戶的密碼
D:\PostgreSQL\11\bin>psql -U postgres
psql (11.5)
輸入 "help" 來獲取幫助信息.
postgres=# alter user postgres with password 'your_password';
ALTER ROLE
postgres=#
記得重新關閉服務, 然后把 trust
改回 md5
后, 重啟服務.
搞定. 又可以歡快的在 pgAdmin 里玩耍啦...