我在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/[email protected]/postmaster.pid" does not exist
Is server running?
也不是9.6版本的pg_ctl:
$ pg_ctl stop
pg_ctl: PID file "/usr/local/var/[email protected]/postmaster.pid" does not exist
Is server running?
$ which pg_ctl
/usr/local/opt/[email protected]/bin/pg_ctl
当pg_ctl似乎无法控制它时,如何关闭服务器?我不记得启动它 - 也许它在机器上次重启时自动启动。我想我用Homebrew安装它但我不确定。
最终工作:
首先,得到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