Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos PG::ConnectionBad升级到Yosemite和postgresql 9.4.4_Macos_Postgresql_Rails 4 2 1 - Fatal编程技术网

Macos PG::ConnectionBad升级到Yosemite和postgresql 9.4.4

Macos PG::ConnectionBad升级到Yosemite和postgresql 9.4.4,macos,postgresql,rails-4-2-1,Macos,Postgresql,Rails 4 2 1,我刚刚将MacOSX更新为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

我刚刚将MacOSX更新为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
我发现是这样的,但我犹豫是否要开始创建一堆目录,除非这真的是我应该做的。我也找到了一个,但不太确定是否是要遵循的

这表明我删除了一个,/usr/local/var/postgres/postmaster.pid,但我没有,我有一个,/usr/local/var/postgres/postmaster.opts——我应该删除postmaster.opts吗


似乎有很多建议,但我不太确定该遵循什么。有人能为我的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

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

显然是更干净的移动。这对我来说非常有效。我必须在
initdb
之后启动数据库,使用
launchctl load~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
.me。如果使用自制,请使用
brew服务重新启动postgresql