家酿postgres破碎

我使用自制软件在我的Mac(10.10.1 / Yosemite)上安装了Postgresql 9.4.0。 这是行不通的。

我创build了〜/ Library / LaunchAgents中的/usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist的软链接。

如果我尝试手动加载postgres我得到的消息,“操作正在进行中”

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

但postgres似乎并没有运行。

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

据我所知,我已经尝试了讨论这个问题的其他 Stackoverflow线程上build议的所有修复。 特别:

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

我早些时候曾经在这台机器上使用过自制的postgres。 我认为是什么打破了从版本8升级到版本9,但我不知道。

我没有任何需要保存的数据库。 我愿意用postgres开始清理; 我只需要现在就开始工作。 有任何想法吗?


这个问题似乎是/ 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 

不知道它是如何进入这个状态,因为我不记得这个目录的权限,但不pipe。 它现在有效。

我在安装新鲜安装的优胜美地时使用自制软件安装postgres也遇到同样的问题。

首先我的brewconfiguration看起来像这样:

 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 。 这很容易改变发出sudo chown -R `whoami` /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/

这似乎已经成功了,postgres运行良好。

我有这个相同的问题。 这里的主要问题是安装的initdb步骤将创build具有超级用户的目录而不是Mac上的用户。 要解决这个问题:

在运行initdb之前创build数据目录并将权限设置为0700

 rm -rf /usr/local/var/postgres # in case this is not your first try mkdir /usr/local/var/postgres chmod 0700 /usr/local/var/postgres 

然后运行initdb ,它将尊重数据目录的权限。

 initdb -D /usr/local/var/postgres 

对于微笑和笑声,创build一个以你的用户命名的testing数据库:

 createdb `whoami` 

logintesting:

 psql 

试图用Homebrew安装postgresql后,我得到这个:

 Warning: postgresql-9.5.2 already installed, it's just not linked 

所以我试了一下:

 brew link postgresql 

并得到这个错误:

 Linking /usr/local/Cellar/postgresql/9.5.2... Error: Could not symlink share/man/man3/SPI_connect.3 /usr/local/share/man/man3 is not writable. 

这似乎是一个写权限的问题,所以我做了:

 sudo chown -R `whoami` /usr/local/share/man/ 

它做的伎俩,因为,那么我能够做到(没有错误):

 brew link postgresql 

请注意,他们是一个线程在Homebrew的github处理这个问题: https : //github.com/Homebrew/homebrew/issues/35240


我有类似的问题。 詹姆斯的回答帮助我解决了它。 但是我碰到了jbk提到的问题(在删除了/ usr / local / var / postgres之后,它不断被重新创build)。

问题是,如果你已经创build了符号链接:

 ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents 

并启动了这个过程:

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

你应该先卸载它:

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

在运行詹姆斯的命令之前。

 rm -rf /usr/local/var/postgres # in case this is not your first try mkdir /usr/local/var/postgres chmod 0700 /usr/local/var/postgres 

另外,如果像我一样,你有一个pipe理用户pipe理自制软件和一个普通用户,他们将使用pgsl作为开发目的,James命令应该以超级用户身份运行:

 sudo -s 

并且对postgres目录的所有权应该交给你的开发者用户:

 chown my-dev-user /usr/local/var/postgres 

下面的命令作为开发用户运行,然后应该正确地填充目录:

 createdb `whoami` 

运行:

 psql -l 

应该在这样的操作之后向你展示postgre中的表和用户权限。

希望这可以帮助。

检查@leo_chaz_maltrait修复错误错误Could not symlink share/man/man3/SPI_connect.3可能出现的另一个错误是:

Error: Could not symlink lib/pkgconfig/libecpg.pc

 sudo chown -R `whoami` /usr/local/lib/pkgconfig brew link postgresql