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

前端之家收集整理的这篇文章主要介绍了忘了postgresql用户的密码.我该如何登录?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我忘记了 postgresql root用户的密码:postgres

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

  1. local all postgres trust
  2. local all all trust
  3. host all all 127.0.0.1/32 trust
  4. host all all ::1/128 trust

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

  1. @omnipresent:~$su - postgres
  2. Password:
  3. su: Authentication failure

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

  1. @omnipresent:~$psql -U postgres
  2. psql (8.4.8)
  3. Type "help" for help.
  4.  
  5. postgres=#

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

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

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

然后:

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

猜你在找的Postgre SQL相关文章