Install homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code

Install postgreSQL

brew install postgresql
Copy the code

Check the version

postgres --version
Copy the code

Initialize the

initdb /usr/local/var/postgres
Copy the code

Start the server

postgres -D /usr/local/var/postgres
Copy the code

Create a user

createuser -a -d username -P
Copy the code

Cancel the user

dropuser username
Copy the code

Creating a database

psql -U postgres
> create database mydb;
Copy the code

Powered up

ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Copy the code