dwyl / learn-postgresql

🐘 Learn how to use PostgreSQL and Structured Query Language (SQL) to store and query your relational data. 🔍
212 stars 23 forks source link

Add Mac Homebrew CLI installation instructions #40

Open macintoshhelper opened 7 years ago

macintoshhelper commented 7 years ago

Installing Postgres took a while for some people in FACN1. There's around an hour dedicated to installation, so shortening the time to a few minutes ideally would be great.

I've created some (copy/paste friendly) bash Mac CLI instructions:

(
  # install postgresql
  brew install postgresql

  # initialise database
  initdb /usr/local/var/postgres

  # start the postgres server
  brew services start postgresql

  # Get user input for database name
  echo 'Please input your desired database name, such as mydb'
  read PSQL_DB_NAME

  # Get logged in username
  PSQL_MY_USERNAME=$(whoami)

  # create your database where $PGSQL_DB_NAME is your desired database name and create database with your username to allow using just 'psql'
  createdb $PSQL_DB_NAME
  createdb $PSQL_MY_USERNAME
);