“根”不允许执行PostgreSQL服务器 [英] "root" execution of the PostgreSQL server is not permitted

查看:2367
本文介绍了“根”不允许执行PostgreSQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试启动postgresql时出现错误:

When I try to start postgresql I get an error:

postgres




postgres不知道在哪里可以找到服务器配置文件。

必须指定- config-file或-D调用选项,或者设置
PGDATA环境变量。

postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.

因此,我尝试设置配置文件:

So then I try to set my config file:

postgres -D /usr/local/var/postgres

我得到以下错误:


postgres无法访问服务器配置文件 /usr/local/var/postgres/postgresql.conf:权限被拒绝

postgres cannot access the server configuration file "/usr/local/var/postgres/postgresql.conf": Permission denied

嗯。接下来,我尝试执行与管理员相同的操作:

Hmm okay. Next, I try to perform that same action as an admin:

 sudo postgres -D /usr/local/var/postgres

我收到以下错误:


不允许对PostgreSQL服务器执行 root操作。

必须以非特权用户ID启动服务器,以防止
可能损害系统安全性。有关如何正确启动服务器的更多
信息,请参见文档。

"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.

我到处搜索该错误消息,但无法找到解决方案。

任何人都可以对此提供一些见识吗?

I googled around for that error message but cannot find a solution.
Can anyone provide some insight into this?

推荐答案

您的命令没有执行任何操作你认为是的。以系统用户的身份运行 postgres

Your command does not do what you think it does. To run something as system user postgres:

 sudo -u postgres command

要运行命令 (也称为 postgres !):

To run the command (also named postgres!):

sudo -u postgres postgres -D /usr/local/var/postgres

您的命令执行相反的操作:

Your command does the opposite:

sudo postgres -D /usr/local/var/postgres

它以超级用户 root (<$$>的身份运行程序 postgres c $ c> sudo 而没有 -u 开关),并且出于安全原因,Postgres不允许以超级用户权限运行。因此出现错误消息。

It runs the program postgres as the superuser root (sudo without -u switch), and Postgres does not allow to be run with superuser privileges for security reasons. Hence the error message.

如果要以系统用户 postgres 的身份运行几个命令,请更改用户:

If you are going to run a couple of commands as system user postgres, change the user with:

sudo -u postgres -i

...并完成后退出

... and exit when you are done.

  • PostgreSQL error: Fatal: role "username" does not exist

如果您以系统用户 postgres的身份运行时看到此错误消息,则文件或包含目录之一的权限出了问题。

If you see this error message while operating as system user postgres, then something is wrong with permissions on the file or one of the containing directories.


postgres无法访问服务器配置文件 /usr/local/var/postgres/postgresql.conf:权限被拒绝
/usr/local/var/postgres/postgresql.conf

postgres cannot access the server configuration file "/usr/local/var/postgres/postgresql.conf": Permission denied /usr/local/var/postgres/postgresql.conf

结束时:

  • Consider instruction in the Postgres manual.
  • Also consider the wrapper pg_ctl - or pg_ctlcluster in Debian-based distributions.
  • And know the difference between su and sudo.

这篇关于“根”不允许执行PostgreSQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆