5

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.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76

5 Answers5

6

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'

Donald Byrd
  • 7,668
  • 4
  • 33
  • 50
Mostav
  • 2,203
  • 15
  • 27
2

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).

Nicolas B.
  • 7,245
  • 17
  • 29
2

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
jojo
  • 1,135
  • 1
  • 15
  • 35
0

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
alizelzele
  • 892
  • 2
  • 19
  • 34
0

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

java_dude
  • 4,038
  • 9
  • 36
  • 61
  • This is referring to SonarQube server login, not the H2 database login of SonarQube. There is no username or password needed by default for internal H2 database login. – jojo Feb 14 '22 at 16:18