【发布时间】:2020-07-17 07:07:58
【问题描述】:
我在不知不觉中下载了PostgreSQL,现在不知道密码,如何找到或更改密码? 我必须重新安装它吗? 请帮忙
编辑:我使用的是 Windows 操作系统
【问题讨论】:
-
您使用的是哪个操作系统?
标签: postgresql change-password forgot-password
我在不知不觉中下载了PostgreSQL,现在不知道密码,如何找到或更改密码? 我必须重新安装它吗? 请帮忙
编辑:我使用的是 Windows 操作系统
【问题讨论】:
标签: postgresql change-password forgot-password
步骤 1. 通过将 pg_dba.conf 记录复制到备用区域或简单地将其重命名为 pg_dba_bk.conf 来强化 pg_dba.conf 记录
步骤 2. 更改 pg_dba.conf 文件,将随附的行作为主行包含在备注行之后。备注行以 # 符号开头。
local all all trust
host all postgres 127.0.0.1/32 trust
步骤 3. 重启 PostgreSQL 服务器 例如,在 Linux 中,您使用以下命令:
sudo /etc/init.d/postgresql restart
步骤 4. 连接到 PostgreSQL 数据库服务器。
psql -U postgres
第五步,修改postgres用户的密码。
ALTER USER postgres with password 'very_secure_password';
第六步,恢复pg_db.conf文件并重启服务器,使用新密码连接PostgreSQL数据库服务器。
sudo /etc/init.d/postgresql restart
【讨论】:
ph_hba.conf 不是pg_dba.conf?