Install postgres in mac by using brew
- brew install postgres
Want to view info about postgres
- brew info postgresql
After installing postgres , better restart your host which will automatically start postgres or you can use following commands to start postgres..
- pg_ctl -D /usr/local/var/postgres start
- pg_ctl -D /usr/local/var/postgres stop -m fast
Modify config file to set password , if you don’t want to set password then leave it as trust .
- file : /usr/local/var/postgres/pg_hba.conf
- host all all 127.0.0.1/32 trust
Just logging with psql and check it
- psql -U postgres
If its thrown error as “Postgres user doesn’t exist” then clean up postgres data by using following commands
- Navigate to file directory : cd /usr/local/var/
- clean up everything : rm -rf *
- initdb -U postgres -D postgres