Mavericks后修复Postgresql

Mavericks后修复Postgresql

本文介绍了升级到OSX Mavericks后修复Postgresql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

A recent upgrade to OSX Mavericks has broken my database connection for my Rails app.

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

When I try to fetch from the database the server returns the following error:

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?

当尝试运行psql时,我得到:

When try to run psql I get:

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


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


I've tried many of the solutions available on the internet. Such reinstalling the pg gem and setting host: localhost in my database.yml. My /usr/local/var/postgres/pg_hba.conf file says:

# 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

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

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

Any solutions on this one? Some solutions suggest I need to change my $PATH to my previous postgres installation as a new version of postgres would be added with Mavericks. How do I find where that is located? It's quite possible it was installed with homebrew but I'm not certain.

推荐答案

如果是通过自制程序安装的,请尝试此操作(来自brew info postgresql)

if you installed it via homebrew, try this (from brew info postgresql)

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

将重新加载它. Postgress.app我的默认设置将找不到您的数据库(您需要将其指向PGDATA目录,并且您可能会遇到版本冲突(如果您在运行9.2且postgress.app为9.3的位置,则将执行dump/restore

Which will reload it. Postgress.app my default will not find your databases (you would need to point it to the PGDATA directory, and you might run into version conflicts (if you where running 9.2 and postgress.app is 9.3, a dump /restore would be in order.

从评论中拉出.

好吧,看来您已经安装了9.2.3,我要做的就是这个.

ok so it looks like you have 9.2.3 installed, what I would do is this.

postgres -D /usr/local/var/postgres

然后全部备份. pg_dumpall > ~/mydatabases.dump

杀死postgres

kill postgres

a brew reinstall postgresql,但警告您将从9.2.3带到9.3.1.然后重新导入所有的数据库.确保遵循关于launchctl东西的卸载/装载上的指示,这时您应该会很好.您还可以考虑使用postgress.app并将数据库导入该应用程序,但是无论如何您都需要备份/转储数据库.

a brew reinstall postgresql , but warning this will bring you from 9.2.3 to 9.3.1. Then reimport all your databases psql < mydatabaes.dump. Making sure to follow the directions on the unload/load for the launchctl stuff, and at that point you should be good. You could also look at using postgress.app and importing your databases into that app, but you would need to backup/dump your database anyway.

这篇关于升级到OSX Mavericks后修复Postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 09:01