【问题标题】:PG::ConnectionBad upgrade to Yosemite and postgresql 9.4.4PG::ConnectionBad 升级到 Yosemite 和 postgresql 9.4.4
【发布时间】:2015-10-27 10:59:42
【问题描述】:

我刚刚将我的 mac OS X 更新为 Yosemite 版本 10.10.4,并将 postgresql 更新为:psql (PostgreSQL) 9.4.4。

在我的 Rails 4.2.1 应用程序上运行 rake db:migrate 后,我的终端会话响应:

rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?

在我的终端会话中简单地输入 psql 也显得有点不对劲:

$ 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"?

从 cat /usr/local/var/postgres/server.log 打印出日志后,我读到:

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

我在 SO 上找到了this answer,但我犹豫是否要开始创建一堆目录,除非我真的应该这样做。我还找到了一个older answer,但不太确定它是否是要关注的。

这个SO answer 建议我删除一个 /usr/local/var/postgres/postmaster.pid,但我没有,我有一个 /usr/local/var/postgres/postmaster.opts - - 我应该删除 postmaster.opts 吗?

似乎有很多建议,但我不太确定要遵循什么。有人可以提供一些建议,让我的 postgresql 数据库在我的 Rails 应用程序上运行吗?

【问题讨论】:

    标签: macos postgresql rails-4-2-1


    【解决方案1】:

    您可以按照官方指南升级数据库:

    brew switch postgres 9.3    # presuming you already installed 9.4.4
    pg_dumpall > outputfile
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    mv /usr/local/var/postgres /usr/local/var/postgres.old
    brew switch postgres 9.4.4
    initdb -D /usr/local/var/postgres
    psql -d postgres -f outputfile
    

    PostgreSQL upgrade

    【讨论】:

    • 绝对是更清洁的举动。这对我来说非常有效。
    • 我必须在initdb 之后使用launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 启动数据库。
    • 我也是。如果使用自制软件,请使用 brew services restart postgresql 重新启动 postgresql
    【解决方案2】:

    基本上,我必须删除并重新创建我自己的数据库,并使用远程暂存数据重新为其播种。我不明白的是,更新数据库的问题在于数据本身也需要以某种方式“更新”。数据与其他版本兼容

    【讨论】:

      猜你喜欢
      • 2019-04-17
      • 2017-08-19
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      • 2014-12-14
      • 1970-01-01
      • 1970-01-01
      • 2017-12-19
      相关资源
      最近更新 更多