流沙团
PostgreSQL 忘记密码
2022-6-2 流沙团

修改文件 pg_hba.conf

将以下这行


host all all 127.0.0.1/32 md5


改为如下:


host all all 127.0.0.1/32 trust


如果开启ipv6的话,以下也要修改


IPv6 local connections:


host all all ::1/128 trust


运行cmd,进入postgres安装路径的bin目录,运行如下命令:

psql -U postgres


postgres=# alter user postgres with password ‘你要设置的密码’;



一定注意要带上分号



postgres=# \q


修改data目录下的 pg_hba.conf 文件

还原 trust -> md5


将以下这行


host all all 127.0.0.1/32 trust


改为如下:


host all all 127.0.0.1/32 md5


ipv6的密码方式也修改


重新启动postgres

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容