Postgres配置在OSX Mavericks之后搞砸了

Jaq*_*aqx 1 postgresql ruby-on-rails-3 osx-mavericks

在我安装了Mavericks后,我的postgres配置似乎完全搞砸了.我从xcode安装了Maverick的开发工具,我尝试在db yml中放置host:localhost但是如果我尝试运行rails s:

could not connect to server: No such file or directory (PGError)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

如果我尝试手动启动postgres:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

我明白了: server starting

但是pg_ctl -D /usr/local/var/postgres status回归pg_ctl: no server running??

我试图重新安装pg gem并重新加载postgresql但无济于事.brew info postgres收益:

postgresql: stable 9.3.1
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.3.1 (2919 files, 39M) *
Run Code Online (Sandbox Code Playgroud)

自从我做了重新安装postgress后我知道得到这个:

The data directory was initialized by PostgreSQL version 9.2, 
which is not compatible with this version 9.3.1.
Run Code Online (Sandbox Code Playgroud)

我有一个postgres查询工具,连接似乎没有任何问题所以我知道数据仍然存在.

如果有人能帮助我解决这个问题,我真的很感激,谢谢.

Bri*_*ian 8

该错误The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.3.1.是由9.2和之间的不兼容数据目录引起的9.3.

如果你不需要在你的旧数据9.2分贝,这是很容易解决这个问题:

rm -rf /usr/local/var/postgres
Run Code Online (Sandbox Code Playgroud)

/usr/local/var/postgres默认数据目录路径在哪里.您可能需要根据您的设置更改路径.

删除旧数据目录后,使用以下命令初始化9.3:

initdb /usr/local/var/postgres -E utf8
Run Code Online (Sandbox Code Playgroud)

那你很高兴去!

====

如果您需要将旧数据迁移9.29.3:

a)重命名旧数据目录:

mv /usr/local/var/postgres /usr/local/var/postgres9.2 
Run Code Online (Sandbox Code Playgroud)

b)初始化一个新的9.3db(创建一个新的数据目录):

initdb /usr/local/var/postgres -E utf8
Run Code Online (Sandbox Code Playgroud)

c)迁移:

pg_upgrade \
-b /usr/local/Cellar/postgresql/9.2.4/bin/ \
-B /usr/local/Cellar/postgresql/9.3.1/bin/ \
-d /usr/local/var/postgres9.2 \
-D /usr/local/var/postgres \
-v
Run Code Online (Sandbox Code Playgroud)

-b是你的旧二进制文件,而-B你的新二进制文件.你可以通过他们brew info postgres.

-d是重命名的旧数据目录,而-D您刚刚创建的新数据目录step b.

那么你会得到以下消息:

Creating script to analyze new cluster                      ok
Creating script to delete old cluster                       ok

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
    analyze_new_cluster.sh

Running this script will delete the old cluster's data files:
    delete_old_cluster.sh
Run Code Online (Sandbox Code Playgroud)

d)用你的postgres摇滚9.3!