postgresql Postgres DB 未在 Mac OSX 上启动:错误表示:Unix 域套接字上的连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17800249/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgres DB not starting on Mac OSX: ERROR says: connections on Unix domain socket
提问by banditKing
I ve installed Postgresql and then ran a bunch of rails apps on my local Mac OSX Mountain Lion and created databases etc. Today after a while when I launched pgAdminIII and tried to launch a database server I got this error:
我已经安装了 Postgresql,然后在我本地的 Mac OSX Mountain Lion 上运行了一堆 Rails 应用程序并创建了数据库等。今天,当我启动 pgAdminIII 并尝试启动数据库服务器时,我收到了这个错误:
A quick google showed thispost. More browsing pointed to the fact that there might be some sort of postmaster.pid file lying around that might be the root cause of this. If I delete that things would be fine.
一个快速的谷歌显示了这篇文章。更多浏览表明可能存在某种 postmaster.pid 文件,这可能是导致此问题的根本原因。如果我删除那些东西就好了。
However, before I go deleting stuff on my computer I wanted to make sure Im debugging this in a systematic way which would not result in more problems.
但是,在我删除计算机上的内容之前,我想确保我以系统的方式对其进行调试,这不会导致更多问题。
Somewhere I read that before deleting that file, I need to run this command:
在删除该文件之前,我在某处读到过,我需要运行以下命令:
ps auxw | grep post
If I get no results then, its OK to delete the file. Else not. Well, I got this result of that command:
如果我没有得到任何结果,则可以删除该文件。否则不行。好吧,我得到了该命令的结果:
AM 476 0.0 0.0 2423356 184 s000 R+ 9:28pm 0:00.00 grep post
So now of course Im throughly confused.
所以现在我当然非常困惑。
So what should I do?
所以我该怎么做?
Here is part of my postgres server error log:
这是我的 postgres 服务器错误日志的一部分:
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 171) running in data directory "/usr/local/var/postgres"?
Postgresql is still not running, still get the same error and nothing has changed. Im too chicken to delete things without checking on SO.
Postgresql 仍然没有运行,仍然出现相同的错误并且没有任何变化。我太鸡了,无法在不检查 SO 的情况下删除东西。
Could some of you experts please guide a noob.
你们中的一些专家能否请指导一个菜鸟。
Thanks
谢谢
采纳答案by banditKing
I have the database working now.
我现在有数据库工作。
Here are the steps I took:
以下是我采取的步骤:
- I rebooted my computer
- I opened the terminal and ran
cd /
- Then I did
ls -la
- Ensured that I could get to
MackintoshHD/usr/local/var/postgres
- Then did
ls -la
- Here I saw the postmaster.pid file
- I ran this command
cp postmaster.pid ~/Desktop
which copied the file to my desktop.I like to do this if I am deleting files. If something does wrong i can put it back - Then I ran this command to remove the file from the postgres
directory
rm -r postmaster.pid
- I went to my pgadmin3 gui and fired it up. and Voila it worked :)
- 我重新启动了我的电脑
- 我打开终端跑了
cd /
- 然后我做了
ls -la
- 确保我可以到达
MackintoshHD/usr/local/var/postgres
- 然后做了
ls -la
- 在这里我看到了 postmaster.pid 文件
- 我运行这个命令
cp postmaster.pid ~/Desktop
将文件复制到我的桌面。如果我要删除文件,我喜欢这样做。如果出了什么问题,我可以把它放回去 - 然后我运行这个命令从 postgres 目录中删除文件
rm -r postmaster.pid
- 我去了我的 pgadmin3 gui 并启动了它。瞧,它奏效了:)
Thanks to @Craig Ringer for his help
感谢@Craig Ringer 的帮助
回答by r3b00t
I had the same problem today on Mac Sierra. In Mac Sierra you can find postmaster.pid
inside /Users/<user_name>/Library/Application Support/Postgres/var-9.6
. Delete postmaster.pid
and problem will be fixed.
我今天在 Mac Sierra 上遇到了同样的问题。在 Mac Sierra 中,您可以在postmaster.pid
里面找到/Users/<user_name>/Library/Application Support/Postgres/var-9.6
. 删除postmaster.pid
并解决问题。
回答by sqren
This can happen if the database did not shut down correctly.
如果数据库没有正确关闭,就会发生这种情况。
To fix it delete the postmaster.pid file:
要修复它,请删除 postmaster.pid 文件:
rm /usr/local/var/postgres/postmaster.pid
Or, back it up:
或者,备份它:
mv /usr/local/var/postgres/postmaster.pid /usr/local/var/postgres/postmaster.pid.backup
回答by Andrew Southard
I'm using Postgres.app, and the below worked for me:
我正在使用 Postgres.app,以下内容对我有用:
I entered the commands into my terminal below, locating the Postgres folder beforehand and not using "justin".
我在下面的终端中输入了命令,事先找到了 Postgres 文件夹,而不是使用“justin”。
$declare -x PGDATA="/Users/justin/Library/Application Support/Postgres/var-9.4"
$pg_ctl restart -m immediate
As Justin explains in his post, the output after this was:
正如贾斯汀在他的帖子中解释的那样,此后的输出是:
waiting for server to shut down……………………………………………………… failed pg_ctl: server does not shut down
等待服务器关闭…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………
After entering the command again:
再次输入命令后:
$pg_ctl restart -m immediate
It worked and I got this message:
它奏效了,我收到了这条消息:
pg_ctl: old server process (PID: 373) seems to be gone starting server anyway server starting LOG: database system was interrupted; last known up at 2015-07-28 18:15:26 PDT LOG: database system was not properly shut down; automatic recovery in progress LOG: record with zero length at 0/4F0F7A8 LOG: redo is not required LOG: database system is ready to accept connections LOG: autovacuum launcher started
pg_ctl:旧的服务器进程(PID:373)似乎已经不在启动服务器了服务器启动日志:数据库系统被中断;last known up at 2015-07-28 18:15:26 PDT LOG: 数据库系统没有正确关闭;正在进行自动恢复 LOG:0/4F0F7A8 处长度为零的记录 LOG:不需要重做 LOG:数据库系统已准备好接受连接 LOG:autovacuum 启动器已启动