如何在MacOS上没有pg_ctl的情况下关闭Postgres 9.6.11?

时间:2019-04-09 22:10:17

标签: postgresql macos pg-ctl

我在MacOS Mojave机器上安装了多个Postgres。版本10.7正在运行,我想将其关闭以启动9.6。

它肯定正在运行:

$ psql -h localhost -U postgres
Password for user postgres:
psql (9.6.11, server 10.7)

但我无法阻止它:

/Library/PostgreSQL/10 $ bin/pg_ctl stop
pg_ctl: PID file "/usr/local/var/postgresql@9.6/postmaster.pid" does not exist
Is server running?

对于pg_ctl 9.6版本也不是:

$ pg_ctl stop
pg_ctl: PID file "/usr/local/var/postgresql@9.6/postmaster.pid" does not exist
Is server running?
$ which pg_ctl
/usr/local/opt/postgresql@9.6/bin/pg_ctl

当pg_ctl似乎无法控制服务器时,如何关闭服务器?我不记得启动它-也许它在机器上一次重启时自动启动了。我想我是用Homebrew安装的,但不确定。

1 个答案:

答案 0 :(得分:0)

这最终成功了:

首先,获取pid:

$ sudo lsof -i:5432
Password:
COMMAND  PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
postgres  73 postgres    4u  IPv6 0x8880707cadb2d1ab      0t0  TCP *:postgresql (LISTEN)
postgres  73 postgres    5u  IPv4 0x8880707cadac18ab      0t0  TCP *:postgresql (LISTEN)

现在将其关闭(SIGTERM):

$ sudo kill -15 73