PG::ConnectionBad 升级到 Yosemite 和 postgresql 9.4.4
PG::ConnectionBad upgrade to Yosemite and postgresql 9.4.4
我刚刚将 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
我找到了 this answer on SO, but I a hesitant to just start creating a bunch of directories unless that's really what I am suppose to do. I also found an older answer,但不太确定它是否是要遵循的那个。
这个 SO answer 建议我删除一个 /usr/local/var/postgres/postmaster.pid,但我没有,我有一个 /usr/local/var/postgres/postmaster.opts -- 我应该删除 postmaster.opts?
似乎有很多建议,但我不太确定要遵循什么。有人可以提供一些关于在我的 rails 应用程序上获取我的 postgresql 数据库 运行 的建议吗?
您可以按照官方指南升级数据库:
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
基本上,我不得不删除并重新创建我自己的数据库,并用远程暂存数据重新播种它。我不明白的是,更新数据库的问题在于数据本身也需要以某种方式 'updated' 。数据与不同版本兼容
我刚刚将 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
我找到了 this answer on SO, but I a hesitant to just start creating a bunch of directories unless that's really what I am suppose to do. I also found an older answer,但不太确定它是否是要遵循的那个。
这个 SO answer 建议我删除一个 /usr/local/var/postgres/postmaster.pid,但我没有,我有一个 /usr/local/var/postgres/postmaster.opts -- 我应该删除 postmaster.opts?
似乎有很多建议,但我不太确定要遵循什么。有人可以提供一些关于在我的 rails 应用程序上获取我的 postgresql 数据库 运行 的建议吗?
您可以按照官方指南升级数据库:
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
基本上,我不得不删除并重新创建我自己的数据库,并用远程暂存数据重新播种它。我不明白的是,更新数据库的问题在于数据本身也需要以某种方式 'updated' 。数据与不同版本兼容