This post documents how to install and manage PostgreSQL using brew package manager for macOS.
To install PostgreSQL using brew, run the following command.
$ brew install postgresql
If you wish to start and stop PostgreSQL, then you do that using following brew commands.
$ brew services stop postgresql $ brew services start postgresql
Create a database for your username
To fix the error
role "postgres" does not exist, run the following command
createuser -s postgres
Now, you will be able to log into psql using both your username and postgres
psql -U postgres
To get information about your PostgreSQL installation, you can run following brew command.
brew info postgresql
There are time you might forget if you installed PostgreSQL using brew. You can check if PostgreSQL was installed by brew by running following command.
brew list |grep postgres
The brew package manager installs PostgreSQL under following location.
The configuration files as inside following directory.