gpt4 book ai didi

linux - Postgres : psql: FATAL: role "postgres" does not exist

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:28:02 29 4
gpt4 key购买 nike

我已经使用 PostgreSQL 几天了,它运行良好。我一直在通过默认的 postgres 数据库用户和另一个具有权限的用户使用它。

今天中午(在一切正常之后)它停止工作,我再也无法回到数据库中。我会尝试:psql,它会出现 psql: FATAL: role "postgres"does not exist

类似地,如果我从我的其他用户那里尝试,psql -d postgres 它会出现 psql: FATAL: role "otheruser"does not exist。 (请注意,我有一个名为 postgres 的数据库,它一直运行到现在)。

更新

似乎其中一台访问服务器的计算机崩溃了,并且可能以某种方式删除了数据库的所有用户。我会尝试重新安装。

最佳答案

psql无法登录的情况下查看哪些用户存在,可以使用以下方法:

  • 停止 postgres
  • 以单用户模式重启它(指定数据目录)
  • 查询pg_user全局表
  • 正常重启postgres

例子:

$ sudo -i -u postgres...postgres@u64:/usr/local/pg95a1$ bin/postgres --single -D $PWD/dataPostgreSQL stand-alone backend 9.5alpha1backend> select usename from pg_user;     1: usename (typeid = 19, len = 64, typmod = -1, byval = f)    ----     1: usename = "postgres"    (typeid = 19, len = 64, typmod = -1, byval = f)    ----     1: usename = "daniel"  (typeid = 19, len = 64, typmod = -1, byval = f)    ----     1: usename = "joe" (typeid = 19, len = 64, typmod = -1, byval = f)    ----     1: usename = "bob" (typeid = 19, len = 64, typmod = -1, byval = f)    ----

ctrlD 终止单用户 session 。

关于linux - Postgres : psql: FATAL: role "postgres" does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31464806/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com