There are a few ways of setting up Postgres on MacOS.
This is what I found worked best for me:
- Install postgres via Homebrew -
brew install postgresql@16 - Start Postgres server -
brew services start postgresql@16 - Check service is running -
brew services list - Add PostgreSQL to PATH -
echo 'export PATH="/opt/homebrew/opt/postgresql/bin:$PATH"' >> ~/.zshrc - Reload the shell -
source ~/.zshrc - Verify psql command -
psql --version - Add a postgres user -
createuser -s -r postgres - Connect to the default postgres database
psql -d postgres - Create a password for the postgres user -
ALTER USER postgres WITH PASSWORD ‘password’;(replace password with your selected password) - Install pgAdmin
- Open pgAdmin and connect to the local Postgres sever (enter password when asked)
If anyone has a better way of doing this, please feel free to let me know. It took some trial and error to get this working for myself.