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
  • Exit out of the PostgreSQL prompt by typing: posgresql=# \q

Configuring Postgres

  • Postgres works pretty hard to make itself usable right out of the box without you having to do anything. By default, it automatically creates the user postgres. Let’s see what other users it has created. Let’s start by using the psql utility, which is a utility installed with Postgres that lets you carry out administrative functions without needing to know their actual SQL commands.
    • Start by entering the following on the command line: psql postgres
    • (You may need to use sudo psql postgres for this command to work, depending on how your system is configured).
Clone this wiki locally