Install, and verify the installation.
$ brew install postgresql
$ postgres —help
postgres is the PostgreSQL server.
...
$ psql --help
psql is the PostgreSQL interactive terminal.
...
Start server instance
$ postgres -D /usr/local/var/postgres
In a separate terminal, create a DB with the same name as the current UNIX user. This makes it easier to access the server with the psql command.
createdb `whoami`
Connect via the CLI
$ psql
Create a database user named fsuser
with a password fspass
.
$ createuser fsuser --createdb --password
Password: fspass
Then create a database named fsbook
with the newly created user.
$ createdb --username=fsuser --password fsbook
Password: fspass
Connect.
$ psql --username=fsuser --password fsbook
$ postgres --version
postgres (PostgreSQL) 9.4.0
$ sw_vers -productVersion # Mac OS X
10.9.5