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-12.2-1-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 (Debian 10 instructions)

1.1 Import the GPG key used for signing packages

sudo apt -y install gnupg2
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

1.2 Add PostgreSQL repository

echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee  /etc/apt/sources.list.d/pgdg.list

1.3 Use the imported linux distribution to install PostgreSQL

sudo apt update
sudo apt -y install postgresql-12 postgresql-client-12

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>';
CREATE ROLE

2.3 Create 'sonar' database

postgres=# create database sonar with owner sonar;
CREATE DATABASE

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)