首页 > 数据库技术 > 详细

PostgreSQL 密码忘了

时间:2020-03-07 19:11:35      阅读:79      评论:0      收藏:0      [点我收藏+]

许久不登, 倒是把默认的 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 里玩耍啦...

PostgreSQL 密码忘了

原文:https://www.cnblogs.com/taadis/p/12435872.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!