无法在mac os x上重启postgres [重复]

这个问题在这里已有答案:

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

试过两种方式:

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"

服务器不会重新启动

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

回答(1)

2 years ago

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

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

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

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

我通过HomeBrew安装了postgres 9.1,以下是它的启动方式:

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