【问题标题】:How to reset PostgreSQL password如何重置 PostgreSQL 密码
【发布时间】:2020-07-17 07:07:58
【问题描述】:

我在不知不觉中下载了PostgreSQL,现在不知道密码,如何找到或更改密码? 我必须重新安装它吗? 请帮忙

编辑:我使用的是 Windows 操作系统

【问题讨论】:

标签: postgresql change-password forgot-password


【解决方案1】:

步骤 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
猜你喜欢
  • 2020-04-06
  • 2021-01-28
  • 2013-09-10
  • 2020-07-09
  • 2022-07-16
  • 1970-01-01
  • 1970-01-01
  • 2010-10-14
  • 2011-05-14
相关资源
最近更新 更多