Configure PostgreSQL in SonarQube

Author
By Darío Rivera
Posted On in Static Code Analysis

In a previous post we saw how to Install SonarQube in its community version. In that post, nothing was configured regarding the database since SonarQube uses an embedded database if one is not configured. Today, we will see how to configure our own dedicated database in PostgreSQL.

If you do not have PostgreSQL installed on your computer yet, or SonarQube, we invite you to check out the following posts.

- Installing PostgreSQL on MacOS
- SonarQube Installation

Creating the user and database

The first thing you should do is to create the database user.

CREATE USER sonarqube;
ALTER USER sonarqube WITH ENCRYPTED password 'mypasssord';

After that, we create the database and assign the user created in the previous command as its owner.

CREATE DATABASE sonarqube OWNER sonarqube;

SonarQube configuration

To configure SonarQube, you must enter the configuration file sonar.properties, which should be in the installation path, and properly disconnect and configure the username and password variables of the database. According to the previous section, this configuration should look like this.

sonar.jdbc.username=sonarqube
sonar.jdbc.password=mypassword

You should also uncomment the following line.

sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube

And finally, to improve performance, activate the server mode by uncommenting or adding the following line.

sonar.web.javaOpts=-server

Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.