2017-04-14 67 views
0

我想在我的机器上使用postgres,并意识到前一段时间我运行brew install postgres并收到Error: postgresql-9.4.5_2 already installed后安装了数据库软件。从那里,我决定安装homebrew/services能够在后台运行的Postgres,并成功启动,并与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 varible: 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服务器来解决,但我不知道是什么文件路径需要清除或清除它们的正确方法。任何人可以提供一些指导?

回答

0

我有同样的问题,我得到了它运行的工作:

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

this guide良好)。