许久不登, 倒是把默认的 postgres 用户的密码给忘了...

首先关闭 PostgreSQL.

我这是 Windows 上安装的, 所以到服务 (services.msc) 里关闭.

PostgreSQL 密码忘了

然后修改配置, 把 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 里玩耍啦...

相关文章:

  • 2022-01-28
  • 2021-12-10
  • 2021-06-20
  • 2022-01-19
  • 2021-05-21
  • 2021-08-31
  • 2021-12-04
  • 2021-09-08
猜你喜欢
  • 2022-02-17
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
相关资源
相似解决方案