Forgot sonarqube password. Using it locally, No Database
Asked Answered
O

5

6

I am using sonarqube from command line. I have a local server (sonarqube 64) on my windows 7 (x86-64). I successfully installed and I can open the web host http://localhost:9000/. but I cannot login the admin/admin login details are not working.

I know there is way of resetting the password but I need database that I don't have and i am the only user/admin.

Is there any way to recover the password or change it? should I uninstall the server and install it again?

It is not said how to properly unistall the server either

Thanks

Obadias answered 19/7, 2017 at 14:2 Comment(0)
S
1

There is no real "installation" for SonarQube; you explode the zip and run one of the start scripts. So if you do decide to scrap your current instance, all you need to do is shut it down, delete the directory and re-explode the zip. However, once you do that, you should seriously consider connecting it to a production database. So far you're running with the embedded H2 database, and that's not appropriate for long-term use. Among other things, migration to new versions is not supported for the H2 database.

Once you've done that, you can reset the admin password by executing the following query:

update users set crypted_password = '88c991e39bb88b94178123a849606905ebf440f5', salt='6522f3c5007ae910ad690bb1bdbf264a34884c6d' where login = 'admin'

That sets it back to 'admin'

Seating answered 19/7, 2017 at 14:5 Comment(4)
Thank you for your answer I've just done it and recovered the admin passwords. I am only evaluating this tool that is why I have not set up DB yet, but I am definitely creating one if we decide to go for SonarQube.Obadias
This is interesting, when I explode the new zip file over my previously exploded zip file, what happens to the project data that was collected a few months back?Nesline
If you're still running the embedded, test-only database, you lose itSeating
I wasn't still, I ran it once for evaluation. and a week later I couldn't login to it. I have followed instructions in quick start at your website to setup the instance and I still don't see anything about choosing test-only database or different database in it, not even a warningNesline
A
17

I'm running 8.5 and this appears to be different, I used:

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

    cd /opt/sonarqube/lib/jdbc/h2

  • Run the command line below to open h2 shell

    java -cp h2-1.4.199.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 [none]

  • Password [none]

You will be prompted now to sql command line (sql>), then type your query:

update users set crypted_password = '$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', salt=null, hash_method='BCRYPT' where login = 'admin'

Antler answered 17/1, 2021 at 14:8 Comment(1)
Note that a ; needs to be added for the sql command to run. Also, for sonarqube 9.7.1, the .jar file is at sonarqube-9.7.1.62043\lib\jdbc\h2\h2-2.1.214.jar. This will vary by your sonarqube version. New password and user will both be admin. Also note that you must have started the sonarqube server for this to work with StartSonar.batMihe
S
1

There is no real "installation" for SonarQube; you explode the zip and run one of the start scripts. So if you do decide to scrap your current instance, all you need to do is shut it down, delete the directory and re-explode the zip. However, once you do that, you should seriously consider connecting it to a production database. So far you're running with the embedded H2 database, and that's not appropriate for long-term use. Among other things, migration to new versions is not supported for the H2 database.

Once you've done that, you can reset the admin password by executing the following query:

update users set crypted_password = '88c991e39bb88b94178123a849606905ebf440f5', salt='6522f3c5007ae910ad690bb1bdbf264a34884c6d' where login = 'admin'

That sets it back to 'admin'

Seating answered 19/7, 2017 at 14:5 Comment(4)
Thank you for your answer I've just done it and recovered the admin passwords. I am only evaluating this tool that is why I have not set up DB yet, but I am definitely creating one if we decide to go for SonarQube.Obadias
This is interesting, when I explode the new zip file over my previously exploded zip file, what happens to the project data that was collected a few months back?Nesline
If you're still running the embedded, test-only database, you lose itSeating
I wasn't still, I ran it once for evaluation. and a week later I couldn't login to it. I have followed instructions in quick start at your website to setup the instance and I still don't see anything about choosing test-only database or different database in it, not even a warningNesline
D
1

For Mac (openjdk-18, sonarqube-10), Sonarqube installed via brew I followed below steps:

  • Locate Sonarqube directory

  • Change directory to /usr/local/Cellar/sonarqube/{version}/libexec/lib/jdbc/h2

  • For me sonarqube version is 10.3.0.82913

    cd /usr/local/Cellar/sonarqube/10.3.0.82913/libexec/lib/jdbc/h2
    
  • Check your h2 version (i.e mine was h2-2.2.222.jar)

  • Run the command line below to open h2 shell

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

you will be prompted to fill the following:

  • URL jdbc:h2:localhost:9000/data/sonar
  • Driver org.h2.Driver
  • User [none]
  • Password [none]

You will be prompted now to sql command line (sql>), then tap your query:

update users set crypted_password = '88c991e39bb88b94178123a849606905ebf440f5', salt='6522f3c5007ae910ad690bb1bdbf264a34884c6d' where login = 'admin';

then used following credentials on browser to login

  • username: admin
  • Password: admin
Donoho answered 4/3, 2024 at 10:23 Comment(0)
G
0

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:localhost:9000/data/sonar

  • Driver org.h2.Driver

  • User sonar

  • Password sonar

You will be prompted now to sql command line (sql>), then tap your query:

update users set crypted_password = '88c991e39bb88b94178123a849606905ebf440f5', salt='6522f3c5007ae910ad690bb1bdbf264a34884c6d' where login = 'admin'

Geronto answered 17/1, 2020 at 17:45 Comment(0)
P
0

For openjdk 17 & sonar 10.5.1 running on localhost

change to dir <sonar_dir>/lib/jdbc/h2 it will have a jar file.

run this java -cp <jar_file_name> org.h2.tools.Shell

you will get a prompt to fill

  • URL jdbc:h2:file:<sonar_dir>/data/sonar
  • Driver org.h2.Driver
  • User <can leave it blank>
  • Password <can leave it blank>

you will get in sql command line, enter the below query and you are good to go

update users set crypted_password = '$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', salt=null, hash_method='BCRYPT' where login = 'admin';

once done you can use admin as username and password as admin to login.

Pronation answered 18/7, 2024 at 14:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.