Laurent Hinoul

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - John F. Woods

How to change Sonar default database

Sonar uses a Derby or H2 as default database. When running Sonar, it says that these databases may only be used for evaluation. Now, in this article, I will tell you how to change the default database and how to configure Maven to use it.


First, download Sonar from its website at Then, extract the zip file and the we can start configuring. Note that I will demonstrate the configuration with a MySQL database. You can use any other database you prefer.


In the sonar folder, go to the conf-folder and open You will see many commented lines. First comment line 48. That’s the connection String to the default database Sonar uses.

Then, I will change line 40 and 41. These are the login credentials to my database. For MySQL, it will be:

After that, we need to uncomment the MySQL connection string. (Note that other database may uncomment more properties).

When that’s finished, we can start Sonar, but before we do that, make sure your database is running and that the Sonar database is created!. To start sonar, go to the bin-folder, select your operating system folder and click on For me, it will be windows-x86-32 and StartSonar.bat. After starting up, a command box will appear, create the needed tales in your database and start up. To see if Sonar is up and running, got to http://localhost:9000

Eclipse plugin

Now sonar is up and running, we need to configure Eclipse and Maven to use sonar. First, install the Eclipse plugin for Sonar. You can find it at After installing the plugin, we need a little configuration in Maven to use the plugin.

Maven configuration

When you run Sonar in Maven without a configuration, Maven will still use the default database. We need to add a profile in the Maven settings. In the .m2 folder, open the settings.xml. Then add the code below. You also need to do that in the settings.xml in your Maven conf folder. You can find other database profiles at

Update Maven in Eclipse

Now sonar and Maven are configured, we need to update your project in Eclipse. Right click on your project in Eclipse, go to Maven en click on Update Project. Then the Maven settings will become active.



Running Sonar in Eclipse

Now we are ready to run Sonar in Eclipse. Right click on your root project, select run as and click on run configurations. Create a new Maven build and insert into your goal: clean install sonar:sonar. Then click on run and your project will show up in Sonar. Enjoy!


8 comments for “How to change Sonar default database

  1. Robert
    26/08/2014 at 12:52

    “…In the .m2 folder, open the settings.xml. Than add the code below. You also need to do that in the settings.xml in your Maven conf folder…”

    I would say it is enough to update one OR the other, but not both.
    If you put the config in .m2/settings.xml, it will only apply to yourself.
    If you put it in conf/settings.xml, it will apply to all users using the same maven-installation.
    If you’re the only user on your machine, it doesn’t matter which you chose.

  2. 07/10/2014 at 17:57

    Ta-Da! Works well for me. Many thanks! You’re a star! 🙂

  3. P
    15/01/2015 at 17:26

    actually, you have to do the same configuration in the sonar runner too 🙂

  4. Jair
    12/06/2015 at 17:52

    Heeeeeeey thank you very much!

  5. Mairead
    11/08/2015 at 11:43

    What changes need to be made to the sonar runner as I have tried the above but when I go to start sonar in the bin folder, it comes to the end of the CMD screen and says it is stopping and then it is stopped.

  6. 24/08/2016 at 18:01

    Hi , We are currently using the default H2 database . We are planning to migrate to mysql . Can you please let me know how can we do that ?

  7. Ken
    29/08/2019 at 16:42

    Commenting the “H2” line from “” doesn’t fix it for me. After a restart the database is still H2. Is there another file somewhere else? SonarQube 7.9.1

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: