PostgreSQL 忘记密码

修改文件 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

原文链接: PostgreSQL 忘记密码 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://www.gyarmy.com/post-744.html )

发表评论

0则评论给“PostgreSQL 忘记密码”