Install Postgres and Sequelize

    Learn to install an SQL database on your Mac OS X

    Bahadir Balban

    Started Tech Buzz


    In this tutorial we install PostgreSQL, and an object relational mapper (ORM) called Sequelize for NodeJS.


    If you can’t get a database connection after below, and things are silently failing, try updating the ‘pg’ package to the latest version. This is a common issue where things silently fail and it comes to mind last.

    Install Homebrew

    /usr/bin/ruby -e "$(curl -fsSL"

    Install PostgreSQL

    brew install postgresql

    Start PostgreSQL

    brew services start postgresql

    Start PostgreSQL shell

    psql postgres

    Create User in PostgreSQL

    CREATE ROLE “express-mvp-dbuser” WITH LOGIN PASSWORD ‘123.456’

    Create Database

    CREATE DATABASE “express-mvp-db”;

    Delete Database

    DROP DATABASE “express-mvp-db”;

    Delete User

    DROP ROLE “express-mvp-dbuser”;

    Install Sequelize and deps

    npm install sequelize --save
    npm install pg --save
    npm install sequelize-cli -g

    Snippet for .sequelizerc

    const path = require('path');
    module.exports = {
      'config': path.resolve('config', 'config.js'),
      'models-path': path.resolve('', 'models'),
      'seeders-path': path.resolve('', 'seeders'),
      'migrations-path': path.resolve('', 'migrations')

    Initialize Sequelize environment

    sequelize init

    Snippet for config/config.js

    module.exports = {
      "development": {
        "username": "express-mvp-dbuser",
        "password": '123.456',
        "database": "express-mvp-db",
        "host": "",
        "dialect": "postgres",
        "port" : 5432
      "test": {
        "username": "root",
        "password": null,
        "database": "database_test",
        "host": "",
        "dialect": "mysql"
      "production": {
        "username": "root",
        "password": null,
        "database": "database_production",
        "host": "",
        "dialect": "mysql"

    Did you like this episode?

    Buzz it and share it with your friends


    You Might Also Like...

    Join The Discussion