gpt4 book ai didi

postgresql - Postgres 不允许更改角色 super 用户,我的默认用户不是 super 用户

转载 作者:行者123 更新时间:2023-11-29 14:36:34 26 4
gpt4 key购买 nike

我无法使用 Elixir 连接到 Postgres:

** (Mix) The database for PhoenixChat.Repo couldn't be created: FATAL 28P01 (invalid_password): password authentication failed for user "postgres"

00:08:59.053 [error] GenServer #PID<0.3214.0> terminating
** (Postgrex.Error) FATAL 28P01 (invalid_password): password authentication failed for user "postgres"
(db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol

我无法理解数据库如何允许在没有 super 用户的情况下创建用户。从我的普通用户那里,它不允许授予 super 用户角色:

$ psql -U thisone --password
Password for user thisone:
psql: FATAL: Peer authentication failed for user "thisone"

$ psql -U fakeuser
psql: FATAL: Peer authentication failed for user "fakeuser"

cchilders=> alter user postgres superuser;
ERROR: must be superuser to alter superusers
cchilders=> select rolname from pg_roles;
rolname
-----------
postgres
cchilders
fakeuser
thisone
(4 rows)

$ psql -U postgres --password
Password for user postgres:
psql: FATAL: Peer authentication failed for user "postgres"

如果没有 super 用户,如何在 Postgres 中给用户 super 用户?

最佳答案

psql: FATAL: Peer authentication failed for user "thisone" 和其他用户同样的错误意味着,你尝试连接不同操作系统用户的套接字(例如,操作系统用户是 cchilders 然后你尝试 psql -U postgres), 而 peer m eans you have to be logged in same OS user .例如,要在 psql -U thisone 中成功,您应该在 sudo su - thisone 之前。如果您没有这样的 OS 用户,则无法使用 peer 身份验证进行连接。因此,要么将 hba_file peer 更改为 trust 以实现无密码,要么将 md5 的密码 auth 更改为 postgres 不是同一操作系统用户...

对于你 sudo -u postgres psql 有效,因为你有 os 用户 postgres(例如 osx 不是这种情况)..

最后,您列出用户,而不是检查他们是否是 super 用户。您应该使用 \du metacommand 和 psql,或者添加 rolsuper` 列,这样它将是:

select rolname from pg_roles where rolsuper;

关于postgresql - Postgres 不允许更改角色 super 用户,我的默认用户不是 super 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43692101/

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