postgresql 无法在 mac os x 上重新启动 postgres

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19147026/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 00:26:42  来源:igfitidea点击:

cannot restart postgres on mac os x

macospostgresql

提问by user2002858

I cannot restart the postgres server on Mac OS X. How can I fix this?

我无法在 Mac OS X 上重新启动 postgres 服务器。我该如何解决这个问题?

Tried two ways:

试过两种方法:

pg_ctl restart returns:

pg_ctl restart 返回:

pg_ctl: PID file "usr/local/var/postgres:/postmaster.pid" does not exist
Is server running?
starting server anyway
pg_ctl: could not read file "usr/local/var/postgres:/postmaster.opts"

The server does not restart

服务器不重启

pg_ctl -D /usr/local/var/postgres restart results in:

pg_ctl -D /usr/local/var/postgres restart 结果:

   pg_ctl: PID file "/usr/local/var/postgres/postmaster.pid" does not exist
   Is server running?
   starting server anyway
   server starting
   LOG:  could not bind IPv4 socket: Address already in use
   HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
   LOG:  could not bind IPv6 socket: Address already in use
   HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
   WARNING:  could not create listen socket for "*"
   FATAL:  could not create any TCP/IP sockets

回答by Mingyu

1 - Your datadirectory might be wrong. Make sure you use the right path.

1 - 您的data目录可能有误。确保使用正确的路径。

2 - If you install more than one postgres, you need to specify which pg_ctlto use.

2 - 如果您安装了多个 postgres,则需要指定pg_ctl使用哪个。

I installed postgres 9.2 manually, here's how I start it:

我手动安装了 postgres 9.2,这是我如何启动它:

/Library/PostgreSQL/9.2/bin/pg_ctl -D /Library/PostgreSQL/9.2/data start

I installed postgres 9.1 via HomeBrew, here's how it gets started:

我通过 HomeBrew 安装了 postgres 9.1,这是它的开始方式:

/usr/local/Cellar/postgresql/9.1.5/bin/pg_ctl -D /usr/local/var/postgres-9.1.5 start