如何在 MacOS 上关闭没有 pg_ctl 的 Postgres 9.6.11?
How to shut down Postgres 9.6.11 without pg_ctl on MacOS?
我在我的 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?
9.6 版本也不行pg_ctl:
$ 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 安装的,但我不确定。
这最终成功了:
首先,获取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
我在我的 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?
9.6 版本也不行pg_ctl:
$ 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 安装的,但我不确定。
这最终成功了:
首先,获取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