加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

忘了postgresql用户的密码.我该如何登录?

发布时间:2020-12-13 16:24:34 所属栏目:百科 来源:网络整理
导读:我忘记了 postgresql root用户的密码:postgres 所以我改变了pg_hba.conf以获得所有内容的信任方法(这是我的本地开发框) local all postgres trustlocal all all trusthost all all 127.0.0.1/32 trusthost all all ::1/128 trust 重新启动服务后,它仍然要求
我忘记了 postgresql root用户的密码:postgres

所以我改变了pg_hba.conf以获得所有内容的信任方法(这是我的本地开发框)

local   all         postgres                          trust
local   all         all                               trust
host    all         all         127.0.0.1/32          trust
host    all         all         ::1/128               trust

重新启动服务后,它仍然要求我输入密码.

@omnipresent:~$su - postgres
Password: 
su: Authentication failure

虽然,我可以通过psql -U postgres登录

@omnipresent:~$psql -U postgres
psql (8.4.8)
Type "help" for help.

postgres=#

我所处理的混乱,此时我只想为postgresql创建一个新角色并使该用户成为管理员.

在这种情况下我该怎么做?

要更改任何linux用户的密码,包括Postgres root:
sudo passwd postgres

然后:

su - postgres
psql -U postgres template1 -c alter user postgres with password 'newpassword';

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读