1

Ok. I have been trying to solve this problem for several days. I installed, uninstalled, and reinstalled Postgresql 3 times. I followed precisely the instructions in this forum: https://dba.stackexchange.com/questions/42048/cant-connect-to-the-postgres-server-ls-tmp-s-pgsql-5432-no-such-file-or-dir

I found this solution in many forums, so I tried to run:

$ mkdir /var/pgsql_socket/
$ sudo mkdir /var/pgsql_socket/
$ ln -s /private/tmp/.s.PGSQL.5432 /var/pgsql_socket/

But this didn't work. When I try to start the server it still says there is another one running and then proceeds to fail every time I try to create a database or type "psql"

I then tried to run the following in order to change the path of the commands from OS X's builtin version of postgres to my version and it seemed to work:

$ cd /usr/local/bin
$ rm postgres
$ ln -s /Library/PostgreSQL/9.2/bin/postgres postgres
$ rm psql
$ ln -s /Library/PostgreSQL/9.2/bin/psql psql
$ rm pg_ctl
$ ln -s /Library/PostgreSQL/9.2/bin/pg_ctl pg_ctl

So then I ran the following to create a user for postgres:

$ sudo -u postgres createuser --superuser $Sarah
$ sudo -u postgres createuser --superuser user_sarah
$ sudo -u postgres psql postgres

But it kept saying "unknown user postgres" I then tried to install the Ruby pg gem, but that also failed, saying there was a problem with necessary libraries.

I have saved a text file of everything I tried to do in the terminal. Let me know if I should post that. Thanks.

update: When I try to run this: $ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start I get this: -bash: /usr/local/bin/pg_ctl: No such file or directory Which is different from a lot of other errors that I have seen posted on this problem.

4

2 回答 2

1

PostgreSQL 的 homebrew 安装不需要创建或需要一个postgres帐户,因此所有提到的做sudo -u postgresps -fu postgres不适用于您的案例。

该命令brew info postgresql输出有关启动和停止它的各种信息,您可以阅读它们。相比之下,您不想盲目相信随机用户告诉他们如何“修复”他们的非工作安装。事实上,网络上有大量关于 MacOS X 上的 PostgreSQL 的糟糕建议,对我来说,你在 dba.se 上链接的答案就是其中之一。从头到尾都是错误的,您应该注意它没有被接受为答案。当然作者的意思很好,但他没有看到他自己的背景不能推广到其他装置。

最糟糕的部分是建议在/usr/local/bin/二进制文件中删除 ,postgres并将它们软链接到内部假定的等效项。对我来说,它只是破坏了自制软件的安装。难怪在这样做之后你会得到这个错误:psqlpg_ctl/Library/PostgreSQL/9.2/bin/

/usr/local/bin/pg_ctl: 没有这样的文件或目录

所以我的回答是使用 brew 重新安装 postgresql 以从干净状态重新启动,然后确保您启动的所有 postgres 命令都是 from ,如果您对任何与 PG 相关的内容有任何疑问,请/usr/local/bin始终首先阅读传递给的服务器日志文件。pg_ctl

于 2013-10-04T13:13:32.733 回答
1

首先,您应该确认没有正在运行的 postmaster:ps -ef | grep 邮政局长。一旦你确认 postmaster 没有运行,你应该查看 postgresql 命令 initd。根据您的服务器安装,它可能已安装也可能未安装。在尝试启动 postgres 之前,您需要创建一个数据库。在我看来,您的安装没有将主要的 postgresql 命令安装到 /usr/bin,pg_ctl 就是其中之一。

仅供参考:postgres 帐户不是登录帐户,它是在安装 postgresql 时自动创建的,因此如果您安装良好,它应该存在。如果 postgres 不在 sudoers 文件中,则不能 sudo as postgres。

于 2013-10-03T20:30:46.970 回答