Mac 上的 Postgres 服务器错误 [不允许“root”执行 PostgreSQL 服务器。服务器必须在非特权用户 ID 下启动]

Kas*_*low 7 homebrew macos-monterey postgresql-14

有人能帮我解决过去几个小时一直困扰我的问题吗?到目前为止,我已尝试了所有建议的解决方案,但似乎找不到任何有效的方法。

错误:

"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.
Run Code Online (Sandbox Code Playgroud)

我将永远感激任何帮助我解决这个问题的人。

小智 0

尝试更改 postgres 中的用户

\n

切换到 postgres 帐户\n通过键入以下内容切换到服务器上的 postgres 帐户:\nsudo -i -u postgres\n您现在可以通过键入以下内容立即访问 Postgres 提示符:\npsql\n这将使您登录到 PostgreSQL 提示符,从这里您可以立即与数据库管理系统进行交互。\n通过键入以下命令退出 PostgreSQL 提示符:\n\\q\n这将使您返回到 postgres Linux 命令提示符。\n访问 Postgres 提示符而不需要切换帐户\n您还可以直接使用 sudo 对 postgres 帐户运行命令 you\xe2\x80\x99d。\n例如,在上一个示例中,系统指示您首先切换到 postgres 用户以进入 Postgres 提示符然后运行 ​​psql 打开 Postgres 提示符。您可以通过使用 sudo 以 postgres 用户身份运行单个命令 psql 一步完成此操作,如下所示:\nsudo -u postgres psql\n这将使您直接登录到 Postgres,而无需中间的 bash shell。\n同样,您可以通过键入以下内容退出交互式 Postgres 会话:\n\\q\n许多用例需要多个 Postgres 角色。继续阅读以了解如何配置这些。

\n