Skip to content

Instantly share code, notes, and snippets.

@erickrawczyk
Created March 14, 2016 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save erickrawczyk/0edcad8db70bbb48c556 to your computer and use it in GitHub Desktop.
Save erickrawczyk/0edcad8db70bbb48c556 to your computer and use it in GitHub Desktop.
Installing PostgreSQL 9.4 on Ubuntu 14.04 or 15.04

Installing Postgres on Ubuntu:

http://www.postgresql.org/download/linux/ubuntu/

  • Install postgres
    • create the file /etc/apt/sources.list.d/pgdg.list
    • add one of the following lines to the file based on ubuntu version:
      • 14.04: deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
      • 15.04: deb http://apt.postgresql.org/pub/repos/apt/ wily-pgdg main
    • import signing key:
      wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
        sudo apt-key add -
    • update apt package lists: sudo apt-get update
    • Install: sudo apt-get install postgresql-9.4
  • configure postgres
    • become postgres superuser sudo -u postgres i
    • open psql (as postgres superuser): psql
    • create user role:
    CREATE USER username AS SUPERUSER CREATEDB CREATEROLE REPLICATION;
    • exit psql: \q
    • run createdb username to create a postgres database named username
    • exit postgres user: exit
  • allow clone access
    • navigate to /etc/postgresql/9.4/main/
    • make backup of conf
    cp pg_hba.conf pg_hba.conf.bak
    • sudo edit /etc/postgresql/9.4/main/pg_hba.conf
    • near the bottom, add your user with method set to trust:
    # Database administrative login by Unix domain socket
    local   all             postgres                                peer
    local   all             username                                trust  #add this line
    • change the rest of the methods to trust
    # "local" is for Unix domain socket connections only
    local   all             all                                     trust
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    # IPv6 local connections:
    host    all             all             ::1/128                 trust
    • save pg_hba.conf and exit
    • restart
  • you should now be able to pg_dump | pg_restore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment