SonarQube default credentials for internal H2 db?

I'm running SonarQube 5.6.1 and am trying to save a view that I created. To do that, I want to take a peek at H2 DB that Sonar (according to it's own readme) uses for internal embedded DB.

I've ran the H2 jar file and in console was able to log in to dummy DB. If SonarQUbe is running, I can't connect.

So, what are default credentials for that DB? Tried my user credentials and admin/admin, none work. Admin/admin is default for SonarQube administrator user.

Upvotes: 6

Views: 9887

Answers (5)

Mostav
Mostav

Reputation: 2612

For the config below (openjdk-11, sonarqube-8), follow the steps:

  • Change directory to /opt/sq/lib/jdbc/h2

    cd /opt/sq/lib/jdbc/h2

  • Run the command line below to open h2 shell

    java -cp h2-1.3.176.jar org.h2.tools.Shell

you will be prompted to fill the following:

  • URL jdbc:h2:tcp://localhost:9092/sonar

  • Driver org.h2.Driver

  • User blank or 'sonar'

  • Password blank or 'sonar'

Upvotes: 7

jojo
jojo

Reputation: 1145

Here are instructions for SonarQube v8.4.2:

After logging in to SonarQube with administration credentials (admin/admin, if you downloaded the vanilla installation), then you can navigate from the top menu labeled "Administration", click on "System", click on "System" drop-down box, and look for the Database section. You will find "user" and "URL". Confirm this is what you expect.

In my default installation, I used the following to log into the H2 console (after ensuring my SonarQube instance is up, I had to restart it since it had been running too long also, I think it must have stalled):

Driver Class: org.h2.Driver
JDBC URL: jdbc:h2:tcp://localhost:9092/sonar

There is no username and password needed. If you want to set one, then you can modify the sonar.jdbc.username and sonar.jdbc.password properties in the your-sonarqube-installation-directory/conf/sonar.properties file. Here's a snippet of it:

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
#sonar.jdbc.username=
#sonar.jdbc.password=

#----- Embedded Database (default)
# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port=9092

Upvotes: 2

java_dude
java_dude

Reputation: 4088

Default is admin/admin version 7.1. Installed using brew.

Upvotes: 0

Nicolas B.
Nicolas B.

Reputation: 7321

The default values are sonar/sonar .

Edit: this was answered at the time of SonarQube 5.6.x. Recent versions (e.g. v6.7 LTS) might have changed to empty username/password (for embedded database).

Upvotes: 2

alizelzele
alizelzele

Reputation: 923

I'm using sonar 6.5 and username password was default values. username is sa without any password. I was able to backup database using following command (from sonar home directory):

java -cp lib/jdbc/h2/h2-1.3.176.jar org.h2.tools.Script -url jdbc:h2:tcp://localhost:9092/sonar

which is the same as:

java -cp lib/jdbc/h2/h2-1.3.176.jar org.h2.tools.Script -url jdbc:h2:tcp://localhost:9092/sonar -user sa

Also if server is down, you still can access database using:

-url jdbc:h2:<SONAR_HOME>/data/sonar -user sa

Upvotes: 0

Related Questions