升级到OSX Mavericks后修复postgresql

Rya*_*ing 22 ruby postgresql macos ruby-on-rails osx-mavericks

最近升级到OSX Mavericks已经破坏了我的Rails应用程序的数据库连接.

当我尝试从数据库中提取时,服务器返回以下错误:

PG::ConnectionBad (could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
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" (fe80::1) and accepting
    TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)

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"?
Run Code Online (Sandbox Code Playgroud)

我已尝试过互联网上提供的许多解决方案.这样重新安装pg gem并在我的database.yml中设置host:localhost.我的/usr/local/var/postgres/pg_hba.conf文件说:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     RyanKing                                trust
#host    replication     RyanKing        127.0.0.1/32            trust
#host    replication     RyanKing        ::1/128                 trust
Run Code Online (Sandbox Code Playgroud)

哪个psql返回: /usr/local/bin/psql


对此有何解决方案?一些解决方案建议我需要将我的$ PATH更改为我以前的postgres安装,因为新版本的postgres将与Mavericks一起添加.我如何找到它的位置?它很可能是用自制软件安装的,但我不确定.

Doo*_*oon 23

如果你通过自制软件安装它,试试这个(来自brew info postgresql)

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Run Code Online (Sandbox Code Playgroud)

哪个会重新加载它.Postgress.app我的默认设置将找不到您的数据库(您需要将其指向PGDATA目录,并且您可能会遇到版本冲突(如果您运行9.2并且postgress.app为9.3,则转储/恢复将按顺序进行).

从评论中提取.

好吧所以看起来你安装了9.2.3,我会做的就是这个.

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

然后把它们全部拿回来. pg_dumpall > ~/mydatabases.dump

杀死postgres

a brew reinstall postgresql,但警告这会带你9.2.39.3.1.然后重新导入所有数据库psql < mydatabaes.dump.确保遵循卸载/加载启动项目的指示,此时你应该是好的.您还可以查看使用postgress.app并将数据库导入该应用程序,但无论如何您还需要备份/转储数据库.


Pet*_*vin 6

tl; dr刚启动Postgres应用程序!

FWIW,在我的小牛队升级之后和之后我获得了完全相同的体验:

  • 安装和启动9.3(在我的Application文件夹中显示为Postgres93)
  • 将9.2移至垃圾箱
  • 由于我的数据库未迁移,因此看到Rails失败

然后我回去了:

  • 退出9.3
  • 从垃圾中恢复了9.2
  • 启动9.2

一切正常!

然后我意识到了

  • 问题是在我的小牛队安装之后,Postgres没有被运行
  • 我之前从未做过任何明确的事情,导致Postgres在启动时运行,但......
  • Mac OS刚刚重启后重启Postgres,因为它之前已经运行过


小智 6

有同样的问题.发现升级很难杀死进程并将postgres pid文件留在那里.所以,不要像我这样的dumbazz并点击重启来升级你的OSX.确保在升级之前干净地关闭所有内容.


jew*_*eer 5

最简单的解决方案是使用正常工作的http://postgresapp.com

要通过自制软件安装,请确保brew update让homebrew再次运行