Instalar
$ brew install postgresql
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/postgresql-12.1.mojave.bottle.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/525a3637cd6f7b7a7e0bfe5adb102483ae01f4be31269aaf4348f6f4291f8a86--postgresql-12.1.mojave.bottle.tar.gz
==> Pouring postgresql-12.1.mojave.bottle.tar.gz
==> /usr/local/Cellar/postgresql/12.1/bin/initdb --locale=C -E UTF-8 /usr/local/var/postgres
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
brew postgresql-upgrade-database
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Summary
? /usr/local/Cellar/postgresql/12.1: 3,217 files, 37.3MB
Verificar status
$ brew services list
postgresql started user /Users/user/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Conectar
$ psql
psql: error: could not connect to server: FATAL: database "user" does not exist
$ psql -U postgres
psql: error: could not connect to server: FATAL: database "postgres" does not exist
Já iniciou banco de dados, por postgres
que não existe?
Este guia funciona muito bem:
https://gist.github.com/ibraheem4/ce5ccd3e4d7a65589ce84f2a3b7c23a3
É necessário criar db e role manualmente, pois eles não existem.
A única solução que encontrei para o homebrew postgresql 14 no macOS monterey é: