Macos 自制博士后

Macos 自制博士后,macos,postgresql,homebrew,Macos,Postgresql,Homebrew,我使用自制软件在Mac(10.10.1/Yosemite)上安装了Postgresql 9.4.0。它不起作用 我已经在~/Library/LaunchAgents中创建了指向/usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist的软链接 如果我尝试手动加载postgres,我会收到“操作正在进行”的消息 然而,postgres似乎没有运行 > ps auxw | grep post billmcn 670

我使用自制软件在Mac(10.10.1/Yosemite)上安装了Postgresql 9.4.0。它不起作用

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

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

然而,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"?
据我所知,我已经尝试了讨论这个问题的线程上建议的所有修复。具体而言:

  • 我已经卸载并重新安装了postgres和附带的Ruby gem。我的机器上没有postgres 8.0版本
  • 我已经验证了psql客户端程序是由Homebrew安装的9.4.0版本,而不是Mac系统二进制文件
  • 我已验证/usr/local/var/postgres/postmaster.pid不存在
  • 我已经重新启动了机器
早些时候,我确实有自制的博士后在这台机器上工作。我想是从版本8升级到版本9破坏了它,但我不确定

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


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

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

我在新安装的约塞米蒂岛上使用自制软件安装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
的写权限。通过发布
sudochown-R`whoami`/usr/local/var/postgres
可以很容易地改变这一点,然后我重新安装了postgresql并完成了

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

其中透露:

postgres无法访问服务器配置文件“/usr/local/var/postgres/postgresql.conf”:没有这样的文件或目录

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

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


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

我也有同样的问题。这里的主要问题是,安装的initdb步骤将创建具有root所有权的目录,而不是作为Mac上的用户。要解决这个问题:

在运行
initdb
之前创建数据目录,并将权限设置为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
对于咧嘴笑和咯咯笑,创建一个以您的用户命名的测试数据库:

createdb `whoami`
登录测试:

psql

请注意,他们是Homebrew github上处理此问题的线程:


我也有过类似的问题。James answer帮我解决了这个问题。但随后我遇到了jbk提到的问题(在删除了/usr/local/var/postgres之后,它一直在被重新创建)

问题在于,如果已创建符号链接:

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
此外,如果像我一样,您有一个管理自制软件的管理员用户和一个将使用pgsl进行开发的普通用户,则James命令应作为超级用户运行:

sudo -s
postgres目录的所有权应授予您的开发人员用户:

chown my-dev-user /usr/local/var/postgres
以开发人员用户身份运行的以下命令应正确填充目录:

createdb `whoami`
运行:

psql -l
在这些操作之后,应该在postgre中显示表和用户权限


希望这有帮助

在尝试用自制软件安装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/
它做到了这一点,因为,那时我能够做到(没有错误):


检查@leo_chaz_maltrait以修复错误错误
无法符号链接共享/man/man3/SPI_connect.3
另一个可能出现的错误是:

错误:无法符号链接lib/pkgconfig/libecpg.pc

sudo chown -R `whoami` /usr/local/lib/pkgconfig

brew link postgresql

如果有人从以前的版本升级,请不要忘记:

brew postgresql-upgrade-database

通过将您现有的数据库升级到您将postgres升级到的版本,这将解决问题。

对于子孙后代,我遇到了这个问题,并想说明什么对我有效

brew uninstall postgres
brew install postgresql@9.5
echo 'export PATH="/usr/local/opt/postgresql@9.5/bin:$PATH"' > ~/.zshrc
# you may need > ~/.bashrc if you use bash
我在High Sierra上运行postgres 11.2。我最近使用
brew postgresql升级数据库从postgres 10升级

我不断收到错误
psql:无法连接到服务器:没有这样的文件或目录
,并且我的server.log指示
是另一个在数据目录/usr/local/var/postgres“”中运行的邮局主管(PID 5894)“

我尝试了几种解决方案,包括重新启动计算机、删除
postmaster.pid
、使用
brew服务重新启动postgres
,但均无效。我最终偶然发现了解决方案:

brew取消postgresql链接和&brew链接postgresql


不知道为什么会这样,但是把它放在这里,这样我以后可以自己参考它!把东西扔到墙上,直到粘上为止

我最近遇到了一个问题,这是从我升级了一些brew更新/升级开始的,主要是python版本等。这对我来说是可行的

brew uninstall postgres
brew install postgresql@9.5
echo 'export PATH="/usr/local/opt/postgresql@9.5/bin:$PATH"' > ~/.zshrc
# you may need > ~/.bashrc if you use bash
我需要pg_转储,pg_恢复等,以便让我的工作

brew install libpq
启动服务

brew services start postgresql@9.5
从这里开始,我希望一切都能正常工作,但所有rails db命令都给出了服务器未运行的错误。这最后一点是拼图中缺失的一块,它最终为我解决了这个问题

gem uninstall pg
gem install pg -v 0.20.0 # which was set in Gemfile
# could also just probably do bundle install instead.
我欠
gem uninstall pg
gem install pg -v 0.20.0 # which was set in Gemfile
# could also just probably do bundle install instead.