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 wil be windows-x86-32 and StartSonar.bat. After starting up, a command box will appear, create the needed tales in you 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. Than 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!


6 comments for “How to change Sonar default database

  1. 07/10/2014 at 17:57

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

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

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

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

    Heeeeeeey thank you very much!

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

  5. 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 ?

Leave a Reply