Forgot sonarqube password. Using it locally, No Database

2 min read 06-09-2024
Forgot sonarqube password. Using it locally, No Database


Forgot Your SonarQube Password? No Database, No Problem!

We've all been there. You're working on your local development environment, excited to start analyzing your code with SonarQube, and then...you realize you can't remember your password. What do you do when you're using SonarQube without a database and you're the only user?

This article will guide you through the process of resetting your SonarQube password, even when you're running it without a database.

Understanding the Problem:

SonarQube stores user credentials and other data in its internal database. When you don't have an external database, SonarQube uses an embedded H2 database. The lack of a separate database makes the password reset process a bit different.

The Solution: Manual Password Reset

Luckily, resetting your password in this scenario is a relatively simple process. Here's how to do it:

  1. Stop SonarQube: Locate your SonarQube installation directory. For most installations, this will be C:\SonarQube. Inside the directory, find the bin folder and then the windows-x86-64 or windows-x86-32 subfolder (depending on your operating system). Run the SonarQube.bat file with the stop parameter:

    C:\SonarQube\bin\windows-x86-64\SonarQube.bat stop
    
  2. Navigate to the Data Directory: Within your SonarQube installation directory, find the data folder. This is where the embedded database files reside.

  3. Locate the sonar.properties file: Inside the data folder, you'll find a subfolder named config. Navigate to this folder and locate the sonar.properties file.

  4. Modify the sonar.properties file: Open the sonar.properties file using a text editor. Locate the following line:

    sonar.jdbc.password=
    
  5. Set a new password: Replace the existing password with your desired new password. For example:

    sonar.jdbc.password=yourNewPassword
    

    Important: This is NOT your SonarQube login password. This is the password used to access the embedded database, which is also used for SonarQube authentication.

  6. Restart SonarQube: Return to your SonarQube installation directory and start the server using the SonarQube.bat file:

    C:\SonarQube\bin\windows-x86-64\SonarQube.bat start
    
  7. Login with your new password: Open your browser and go to http://localhost:9000. Log in using your new password.

Additional Notes:

  • Security: This method directly modifies the embedded database and should only be used when you are the sole user and administrator. For production environments with multiple users, utilize SonarQube's built-in password recovery feature or use a dedicated database.
  • Backups: Always create a backup of your data directory before making any modifications. This will help you restore your environment if something goes wrong.

Further Resources:

Let me know if you have any other questions. Happy coding!