我用brew 软件在Mac(10.10.1/约塞米蒂)上安装了Postgresql 9.4.0.它不起作用.

我已经创建了指向/usr/local/opt/postgresql/homebrew的软链接.mxcl.postgresql.plist in~/Library/LaunchAgents.

如果我试图手动加载postgres,我会收到"操作正在进行"的消息

> launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
/usr/local/Cellar/postgresql/9.4.0/homebrew.mxcl.postgresql.plist: Operation already in progress

然而,博士后似乎没有参加.

> ps auxw | grep post
billmcn           670   0.0  0.0  2424272    452 s000  R+   10:12PM   0:00.01 grep post

我无法与命令行客户端连接.

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

据我所知,我已经在讨论这个问题的other Stackoverflow个线程上try 了所有建议的修复.明确地:

  • 我已经卸载并重新安装了postgres和附带的Ruby gem.我的机器上没有postgres 8.0版本.
  • 我已经验证了psql客户端程序是由Homebrew安装的9.4.0版本,而不是Mac系统二进制文件.
  • 我已经验证了/usr/local/var/postgres/postmaster.pid不存在.
  • 我重新启动了机器.

我之前确实有brew 的博士后在这台机器上工作.我想是从8版升级到9版让它崩溃了,但我不确定.

我没有任何需要保存的数据库.我愿意从博士后开始;我现在只需要让它开始工作.有什么 idea 吗?


问题似乎是/usr/local/var/postgres目录上的权限.下面是我的var目录在不起作用时的样子.

ll /usr/local/var/
drwxr-xr-x  3 billmcn  admin  102 Dec 20 12:44 cache
drwxr--r--  2 root     admin   68 Dec 29 21:37 postgres

(whoami="billmcn")

我删除了/usr/local/var/postgres,卸载并重新安装了postgres,现在看起来是这样的.

ll /usr/local/var/
drwxr-xr-x   3 billmcn  admin  102 Dec 20 12:44 cache
drwx------  23 billmcn  admin  782 Dec 30 10:51 postgres

我不确定它是如何进入这种状态的,因为我不记得在这个目录上使用权限,但没关系.现在可以了.

推荐答案

我在新安装的优胜美地上使用brew 软件安装postgres时也遇到了同样的问题.

首先,我的brew配置如下所示:

HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: 9f6926265f8e4be7cc80dfe9042f2cd3c1e8dc9e
Last commit: 64 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit sandybridge
OS X: 10.10.1-x86_64
Xcode: 6.1.1
Clang: 6.0 build 600
X11: N/A
System Ruby: 2.0.0-481
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: ~/.rvm/rubies/ruby-2.1.1/bin/ruby

我注意到的第一件事是我没有写/usr/local/var/postgres的权限.这很容易改变,然后我重新安装了postgresql

cat /usr/local/var/postgres/server.log

结果显示:

postgres cannot access the server configuration file "/usr/local/var/postgres/postgresql.conf": No such file or directory

因此,我删除了目录/usr/local/var/postgres,并发出了初始化数据库的命令.

initdb -D /usr/local/var/postgres/

这似乎起到了作用,博士后表现良好.

Postgresql相关问答推荐

PostgreSQL:如何 for each 唯一的客户输入/更新列中的数据,并将其递增1直到表的末尾

Docker化的PostgreSQL:FATAL:用户&postgres的密码身份验证失败

尽管违反了部分索引约束,Postgres 插入仍在发生

使用 pgAdmin 4 v7.4 在 Windows 11 上全新安装 PostgreSQL 15.3-3 无法启动 - 卡在正在加载 pgAdmin 4 v7.4...

在连接字符串并将其附加到 PostgreSQL 中的 where 子句时出现语法错误.怎么修?

gitlab在ubuntu上安装duplicate schema问题

无法从 docker-compose 上的其他服务解析 postgres 主机名

Postgres 低估了导致错误查询计划的行数

如何在 PostgreSQL 中使用正则表达式删除单词之间的所有特殊字符和多余空格

如何将 NULL 值插入 UUID 而不是零

如何在 postgresql 中创建一个空的 JSON 对象?

等效于 Postgresql 中的 FOUND_ROWS() 函数

PostgreSQL 可以对数组元素有唯一性约束吗?

如何在 PostgreSQL 触发器函数中获取表名?

如何使用字符串作为 PostgreSQL 咨询锁的键?

Postgres 删除表语法错误

我怎样才能知道 Postgresql 表空间中有什么?

如何在带有 PostgreSQL 数据库的 Web 应用程序中拥有完整的离线功能?

为什么 rake db:migrate 有时会在 structure.sql 中添加尾随空格?

使用python将数据从csv复制到postgresql