macos - PG::ConnectionBad 升级到 Yosemite 和 postgresql 9.4.4

标签 macos postgresql rails-4-2-1

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

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

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?

在我的终端 session 中简单地输入 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

我找到了 this answer在 SO 上,但我犹豫要不要开始创建一堆目录,除非那真的是我想做的。我还找到了一个 older answer但我不太确定它是否是要遵循的那个。

SO answer建议我删除一个,/usr/local/var/postgres/postmaster.pid,但我没有,我有一个,/usr/local/var/postgres/postmaster.opts——我应该删除 postmaster。选择?

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

最佳答案

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

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

关于macos - PG::ConnectionBad 升级到 Yosemite 和 postgresql 9.4.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31819446/

相关文章:

java - 如何在 Quaqua 中获得统一的工具栏?

MacOS:NSPredicate 查找 "one to one"关系不为零的地方

macos - Lion 更新删除了 'postgres' 用户。如何恢复?

postgresql - 迁移 postgress 出错,我有两列,为什么?

sql - 加入时 Postgres 子查询运行极其缓慢

sql - 按寄存器显示所有授权

c++ - MacOS 上Qt GUI Widget 大小异常

sql - 找不到本地 psql 命令

ruby - 调试级别 Rails - 级别 ":debug"显示所有日志。我只想要错误。是否可以?

ruby-on-rails - 将 Rails 3.2 升级到 Rails 4.2 获得 401 未授权