Skip to content

PostGreSQL installation

Akshay Sharma edited this page May 3, 2018 · 6 revisions

Wiki to install relational database PostGreSQL on different platforms.

Mac

  • Getting Homebrew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Installing PostgreSQL: brew install postgresql
  • Let’s go ahead and start Postgres running, and make sure Postgres starts every time your computer starts up. Execute the following command: pg_ctl -D /usr/local/var/postgres start && brew services start postgresql
  • Finally, let’s make sure Postgres is installed and running. Let’s check what version is running: postgres -V

Ubuntu

  • $ sudo apt-get update
  • $ sudo apt-get install postgresql postgresql-contrib
  • $ sudo -i -u postgres
  • $ psql

Configuring Postgres for the project

  • Login to the PostgreSQL console, by typing psql in the terminal.
  • If you have not created the DB, type CREATE DATABASE sih17;, this will create the database required for the project.
  • Now the since the DB has been created, we need to associate a user to the db, we can do this by typing CREATE USER sih17_admin WITH PASSWORD 'sih17winners'; in the PostgreSQL console.
  • Give full access to the db by:
    • ALTER ROLE sih17_admin SET client_encoding TO 'utf8';
    • ALTER ROLE sih17_admin SET default_transaction_isolation TO 'read committed';
    • ALTER ROLE sih17_admin SET timezone TO 'UTC';
    • GRANT ALL PRIVILEGES ON DATABASE sih17 TO sih17_admin;
  • These steps should be good enough to set up the project.