I was surfing the web looking for help to start a postgres db and stumbled upon these 3 different commands. Could anyone explain their differences and use cases please ? I'm using macOS Monterey, btw, and installed postgres with Homebrew.
brew services start postgresql
pg_ctl -D /usr/local/var/postgres start
/usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres
CodePudding user response:
The last one postgres
(except giving it 'start' on the command line doesn't make any sense) is the lowest level one, the others are just ways to invoke that one with the right options and environment and user and timing and such. The only time I would use that one manually is for debugging purposes or recovering a severely hosed server.
pg_ctl is a slightly more sophisticated wrapper. You would generally use that if you compiled from sources, rather than using a package manager.
If you installed it with Brew, presumably you would want to start and stop it with Brew.