Postgres - 自制软件安装无法找到多个版本的服务器文件

时间:2017-04-14 11:49:41

标签: postgresql homebrew

我正在尝试在我的计算机上使用postgres,并意识到前一段时间我在运行brew install postgres并接收Error: postgresql-9.4.5_2 already installed后安装了数据库软件。从那里我决定安装homebrew/services以便能够在后台运行postgres并成功启动并关闭后台工作

brew services start postgresql==> Successfully started的PostgreSQL (label: homebrew.mxcl.postgresql)

然而,当我运行postgres时,我收到错误:

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上回答问题时cat /usr/local/var/postgres/server.log我收到以下错误:

LOG:  skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.5.

这让我觉得我安装了较旧版本的PostgreSQL需要删除。

然后我尝试了psql并收到了:

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

最后决定使用initdb /usr/local/var/postgres初始化一个新的数据库,但是没有修复它,导致跟踪原始消息并设置了一个env变量:export PGDATA=/usr/local/var/postgres。再次尝试postgres后,我收到了

LOG:  skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.5.

这告诉我的是,显然存在版本兼容性问题,需要解决才能启动我的postgres服务器,但我不确定需要清除哪些文件路径或清除它们的正确方法。任何人都可以提供一些指导吗?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我通过运行来实现它:

pg_ctl -D /usr/local/var/postgres start && brew services start postgresql

this guide很好)。