Reputation: 126145
I have multiple installations of Postgres on my MacOS Mojave machine. Version 10.7 is running, and I want to shut it down, in order to start 9.6.
It's definitely running:
$ psql -h localhost -U postgres
Password for user postgres:
psql (9.6.11, server 10.7)
But I can't stop it:
/Library/PostgreSQL/10 $ bin/pg_ctl stop
pg_ctl: PID file "/usr/local/var/[email protected]/postmaster.pid" does not exist
Is server running?
Nor with the 9.6 version of 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
How can I shut down the server, when pg_ctl doesn't seem to be able to control it? I don't recall starting it - perhaps it automatically started when the machine last rebooted. I think I installed it with Homebrew but I'm not certain.
Upvotes: 1
Views: 3525
Reputation: 126145
This ended up working:
First, get the 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)
Now shut it down (SIGTERM):
$ sudo kill -15 73
Upvotes: 4