Database Installation

If you have no RDBMS on your machine yet, pick one from the supported ones (scroll down to the "Database" section). In our case, and to show a complete case installation, we have choosen PostgreSQL as our preferred database.

As the database is of critical importance to SonarQube operation, it is highly recommended that you implement a backup and restore policy. As this is dependent not only on the RDBMS engine, but also the system environment, this will not be covered in this guide.

1. Get PostgreSQL

1.1 Visit PostgreSQL download page

1.2 Select the latest version of PostgreSQL and Windows x86-64 as your operating system

1.3 Download the installer, in this example we will get postgresql-9.6.2-4-windows-x64.exe, to your Downloads folder

2. Install PostgreSQL

2.1 Intall the downloaded file, following the wizard steps

3. Create 'sonar' database

3.1 Use pgAdmin (installed previously next to the database) to open the PostgreSQL console

3.2 Select the postgres database and then select Tools > Query Tool

3.2 Create 'sonar' user

create user sonar with password '<mypassword>';

2.3 Create 'sonar' database

create database sonar with owner sonar;

2.4 Update the pgAdmin database panel to check the database has been created properly

1. Install PostgreSQL

1.1 Use your linux distribution to install PostgreSQL

$ sudo apt-get install postgresql-9.4 postgresql-client-9.4

2. Create 'sonar' database

2.1 Access to PostgreSQL console

$ sudo -u postgres psql postgres

2.2 Create 'sonar' user

postgres=# create user sonar with password '<mypassword>';

2.3 Create 'sonar' database

postgres=# create database sonar with owner sonar;

2.4 List your databases to check 'sonar' has been created properly

postgres=# \list
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
 postgres  | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 |
 sonar     | sonar    | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 |
 template0 | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(4 rows)