Setting up a PostgreSQL Database on Linux for JIRA

The latest official documentation on configuring JIRA with PostgreSQL can be found in the Connecting JIRA to PostgreSQL guide.

This is a step-by-step supplement guide for setting up your PostgreSQL database for JIRA on Ubuntu. However, the various procedures described below can be adapted (or may be applicable) to other Linux distributions too.

Set up PostgreSQL and create a user

PostgreSQL is very easy to set up on Ubuntu:

user:~$ sudo apt-get install postgresql-8.4 postgresql-client-8.4
Reading package lists... Done
Building dependency tree
....
 * Starting PostgreSQL 8.2 database server             [ OK ]

Now we create a jira PostgreSQL user for the user account that runs JIRA to connect as:

user:~$ sudo su - postgres
postgres:~$ createuser -P jira
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
CREATE ROLE

Connect and set up a PostgreSQL database

We can now connect as our jira user and create a database.

postgres:~$ logout
user:~$ sudo su - jira
jira:~$ createdb jiradb
CREATE DATABASE

Start JIRA

Run the Setup Wizard

Point a browser at http://localhost:8080/, and set up JIRA as described in the Setup Wizard.

Was this helpful?

Thanks for your feedback!

9 Archived comments

  1. User avatar

    Theo Barker

    There seems to be a sequencing issue here. Make sure to run the installer atlassian-jira-<version>-<x64|i386>.bin before the above. The installer script will create the "jira" user. If you don't, you must manually create the user "jira" before executing the "sudo su - jira" command.

     

    30 Oct 2013
  2. User avatar

    Malte Helmhold

    user:~$ sudo apt-get install postgresql-8.2 postgresql-client-8.2 produces: 
    

     

    E: Package 'postgresql-8.2' has no installation candidate

    E: Unable to locate package postgresql-client-8.2

    E: Couldn't find any package by regex 'postgresql-client-8.2'

    in ubuntu  12.04 and 14.04! 
    please fix your doc.
    Malte Helmhold
    10 Jul 2014
  3. User avatar

    Malte Helmhold

    Please use:

    sudo apt-get update

    sudo apt-get upgrade

    (confirm with y while upgrading!

    Then install postgres with this command:

    sudo apt-get install postgresql postgresql-contrib

     

    10 Jul 2014
  4. User avatar

    Kelly Schoenhofen

    Ubuntu 14.04 now ships with Postgres 9.1; starting with 9.1 createuser was changed to not ask you the superuser/create db/roles questions by default, you have to add --interactive to trigger those questions. Your docs should reflect something along the lines:

    Postgres 9.1 and later:

    becomes

    Thanks.

    -Kelly G. Schoenhofen

     

     

     

    24 Sep 2014
  5. User avatar

    Julia Simon [Atlassian]

    I get this error: 

    $ sudo su - jira
    No passwd entry for user 'jira'

    15 May 2015
    1. User avatar

      Theo Barker

      See my comment above for why you got that error.

      15 May 2015
      1. User avatar

        Julia Simon [Atlassian]

        Yes, I saw it.

        postgres@ubuntu:~$ createuser --interactive -P jira
        Enter password for new role:
        Enter it again:
        Shall the new role be a superuser? (y/n) n
        Shall the new role be allowed to create databases? (y/n) y
        Shall the new role be allowed to create more new roles? (y/n) n
        postgres@ubuntu:~$ logout
        jsimon@ubuntu:~$ sudo su - jira
        No passwd entry for user 'jira'

        I need to also create the user in the system:

        sudo adduser jira
        15 May 2015
        1. User avatar

          Kelly Schoenhofen

          I think most people avoid this gap in the documentation because the database user account they create is the same account name as the service account they are using to run JIRA with. Which I bet 80% of the time is "jira". 

          15 May 2015
  6. User avatar

    Damu Liu

    I have centos Linux with postgres. createdb is owned by root, so it doesn't work for me. what I did is to login with root, or using sudo should be ok, and:

    • su - postgres
    • psql
    • postgres=# create role jira login password 'bla';
    • postgres=# create database jiradb encoding 'UTF8' owner jira;
    • postgres=# \l shows:

      Name | Owner | Encoding | Collate | Ctype | Access privileges
      -----------+----------+----------+-------------+-------------+------------------
      jiradb | jira | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

     

     

    21 Jun 2015
Powered by Confluence and Scroll Viewport