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

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

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英里时,我得到:

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

我try 过互联网上的许多解决方案.比如在我的数据库中重新安装pg gem并设置host:localhost.yml.My/usr/local/var/postgres/pg_hba.档案上写着:

# 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,因为新版本的postgres将添加Mavericks.我如何找到它的位置?它很可能是用brew 软件安装的,但我不确定.

推荐答案

如果你是通过brew 软件安装的,试试这个(从brew info postgresql开始)

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

这将重新加载它.Postgress.app my default将找不到您的数据库(您需要将其指向PGDATA目录,并且可能会遇到版本冲突(如果运行9.2和postgress.app的位置是9.3,则转储/还原是正确的).

来自 comments .

看起来你已经安装了9.2.3,我要做的就是这样.

postgres -D /usr/local/var/postgres 

然后把它们都备份起来.pg_dumpall > ~/mydatabases.dump

杀死博士后

brew reinstall postgresql,但警告这会让你从9.2.3降到9.3.1.然后重新导入所有数据库psql < mydatabaes.dump.确保按照launchctl内容的卸载/加载说明进行操作,在这一点上,你应该很好.你也可以看看如何使用postgress.并将您的数据库导入该应用程序,但您仍需要备份/转储数据库.

Postgresql相关问答推荐

为什么在PostgreSQL中CPU_INDEX_TUPLE_COST与CPU_TUPLE_COST不同

为什么更新不设置较晚的结束时间?

时间戳的postgreSQL-to_char如果为零,则不显示微秒

INSERT 语句返回策略违规(USING 表达式)

Postgres 生成的列不是不可变的

将一列与另一列的每个元素进行比较,该列是一个数组

联合所有 postgresql Select 子句保留顺序

如何展平也在关系中使用的区分大小写的列

JPA findBy 字段忽略大小写

在 KnexJS 中插入

Django + Postgres + 大时间序列

在 Ubuntu 11.04 服务器中启用对 postgresql 的 PHP 支持

将 Postgres 与 Grails 一起使用

SQLAlchemy 中使用什么类型存储字节字符串?

MAC OS X 上的 Postgres 权限被拒绝

判断值是否存在于列中

如何使用 Django Migrations 重新创建已删除的表?

PostgreSQL:如何在用户级别设置 search_path?

有没有办法确保 WHERE 子句在 DISTINCT 之后发生?

删除空行