postgresql-10:pg_ctl 需要程序 "initdb",但未在与 "pg_ctl" 相同的目录中找到程序 "initdb" 检查您的安装

postgresql-10 : The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl" Check your Installation

我是这个论坛的新手,我遇到了这个问题,我收到以下错误。

sudo -u shahid ./pg_ctl -D /root/pgsql10x/data/ initdb
invalid binary "/root/pgsql10x/bin/pg_ctl"
invalid binary "/root/pgsql10x/bin/pg_ctl"
invalid binary "/root/pgsql10x/bin/pg_ctl"

The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl".

Check your installation.

我正在尝试 运行 从 root 执行此操作。

我从源代码构建。我正在 CentOS7 上尝试版本 10.。 我直接从 postgres 站点下载。

当我 运行 作为非 root 用户时,我没有遇到这个问题。

我有 bin 目录中的所有文件,如图所示:

我终于解决了这个问题。

问题是因为构建的源码直接放在“/root/”目录下 /root/pgsql10x/ 在 root 登录中。

当我将它作为 /app/pgsql10x/ 放置在“/app/”目录中时,事情开始正常工作,数据库创建并且数据库正常工作(在 root 登录中)。

-沙希德

错误是因为您正在尝试以 root 用户身份启动集群,您必须切换到 postgres 并再次尝试重新启动集群

su - postgres
pg_ctl start