-
Install Postgres
brew install Postgres
-
Try to log in.
$ psql -h localhost -d postgres -U postgres psql: error: could not connect to server: FATAL: role "postgres" does not exist
-
Create the user
$ /usr/local/opt/postgres/bin/createuser -s postgres
-
Start the server
$ pg_ctl -D /usr/local/var/postgres start pg_ctl: another server might be running; trying to start server anyway waiting for server to start....2020-06-27 18:12:07.784 +08 [20812] FATAL: lock file "postmaster.pid" already exists 2020-06-27 18:12:07.784 +08 [20812] HINT: Is another postmaster (PID 4901) running in data directory "/usr/local/var/postgres"? stopped waiting pg_ctl: could not start server Examine the log output.
It just works!!
$ psql -h localhost -d postgres -U postgres
psql (12.3)
Type "help" for help.
postgres=#
References
- https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist
- https://stackoverflow.com/a/35308200/1357375
Written with StackEdit.