【问题标题】:Unable to retrieve postgres password无法检索 postgres 密码
【发布时间】:2016-05-09 13:34:12
【问题描述】:

我知道围绕这些东西有很多问题,但我遇到的问题是 我很久以前就安装了 Postgres,但是当我尝试 reset my password according to this 时,第三条指令建议打开“pg_hba.conf” 文件。但是打开文件也需要密码。所以在谷歌搜索决定删除现有设置之后,它也在询问密码。

请帮帮我

【问题讨论】:

  • 在哪个平台上?窗户,Linux...
  • @Tommaso Di Bucchianico linux 平台
  • pg_hba.conf 的访问由您的操作系统控制。通常,该文件(以及所有其他 Postgres 配置文件)归 Linux 用户 postgres 所有。因此,您要么需要su postgres,要么使用root 帐户来更改该文件。
  • 要编辑您的 pg_hba.conf 文件,您需要以系统管理员身份打开该文件。见ccm.net/faq/…。 “删除现有设置”是什么意思?您是否重新安装了 PostgreSql?
  • @a_horse_with_no_name,是的,我有 sudo 权限。

标签: postgresql postgresql-9.3 psql pgadmin


【解决方案1】:

可能您的服务器已经为用户 postgres 提供了 ident 登录选项。 如果是这样,您可以先通过sudo su postgres 登录,而不是在终端中使用psql

sudo su postgres
psql

如果这确实有效,但您想使用密码而不使用 sudo 登录,则需要设置密码,修改 pg_hba.conf 并重新加载 Postgres 服务器

1) 为用户 postgres 设置密码: 如上所述在 psql 中登录,而不是在 psql 中:

ALTER USER postgres WITH ENCRYPTED PASSWORD 'your_password';

2) 修改您的 pg_hba.conf。 Open the file as administrator 并更改此行

local all postgres ident

到这里

local all postgres md5

3) 现在重新加载 postgres 服务器:

sudo service postgresql reload

现在您可以使用用户 postgres 登录了吗:

psql -U postgres

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-16
    • 1970-01-01
    • 2019-01-28
    • 2019-07-28
    • 2013-09-20
    • 2018-02-04
    • 2011-01-11
    • 1970-01-01
    相关资源
    最近更新 更多