【问题标题】:Yosemite Upgrade & Postgres Connection Issues [duplicate]优胜美地升级和 Postgres 连接问题 [重复]
【发布时间】:2015-03-24 13:00:31
【问题描述】:

ETA:上面的可能答案不能回答我的问题。我无法创建这些目录。

去 Apple Store 维修后,我的 macbook 回来升级了 Yosemite。除了 Postgres,我的开发环境运行良好。我重新安装了自制软件,当我在终端中输入“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"?

我已经尝试了网站上的几乎所有建议,但无济于事。每当我尝试更改任何内容时,都会被拒绝,即使使用 SUDO 也无法正常工作。

我尝试过的一些事情:

$pg_ctl initdb

结果:

The files belonging to this database system will be owned by user "**********". This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /var/lib/pgsql/data ... initdb: could not create directory "/var/lib/pgsql": Permission denied pg_ctl: database system initialization failed

我试过用Lunchy

$ lunchy start postgres /usr/local/Cellar/postgresql/9.4.0/homebrew.mxcl.postgresql.plist: File exists started homebrew.mxcl.postgresql

没用。

也试过了:

$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents ‘/Users/**************/Library/LaunchAgents/homebrew.mxcl.postgresql.plist’ -> ‘/usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist’

还有其他一些方法。

Postgres 位于此处:/usr/local/bin/postgres 在我的计算机上。应该搬家吗?

有没有人可以尝试一步一步的说明?我觉得我已经尝试了一切,我真的很茫然,因为它不应该这么困难。谢谢!

【问题讨论】:

  • 我认为this answer 应该可以帮助您解决问题。
  • 感谢您的快速回复。当我尝试创建目录时,权限被拒绝,即使使用 sudo 也无法正常工作。无论出于何种原因,我都无法创建这些目录。
  • Homebrew 安装的 Postgres 将其文件放入 /usr/local/var/postgres,而不是放入 /var/lib。您可能已经安装了两次 Postgres,一次通过 Homebrew,一次通过其他方式(Macports?一些像 EnterpriseDB 这样的二进制安装程序?)。确保which pg_ctl 返回/usr/local/bin/pg_ctl。如果没有,请直接运行/usr/local/bin/pg_ctl,或者最好删除第二次安装的 Postgres。
  • 请将/usr/local/bin/pg_config完整输出添加到您的问题中。
  • @janfoeh 非常感谢您迄今为止的所有帮助 /usr/local/var/postgres 确实作为目录存在,当我运行 pg_ctl start -D /usr/local/var/postgres 它给了我 pg_ctl: could not open PID file "/usr/local/var/postgres/postmaster.pid": Permission denied 然后当我 sudo 我得到 pg_ctl: cannot be run as root .我不确定如何检查该目录中的 sever.log 是否有错误,不幸的是我的开发环境是为我设置的,我现在正在学习这个

标签: sql ruby-on-rails macos postgresql


【解决方案1】:

我刚刚在CoderWall 的帮助下自己解决了这个问题。我的问题是 /usr/local/var/postgres/ 中缺少一些目录

CoderWall 提供的单行修复:

mkdir -p /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat_tmp}

我在开头标记了一个 sudo,以确保它可以正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多