Sonarqube admin login fails even after resetting

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension) – community build
  • how is SonarQube deployed: zip, Docker, Helm – docker
  • what are you trying to achieve – build a sonarqube server to test our code.
  • what have you tried so far to achieve this-- installed sonarqube the UI is up but not able to login with admin/admin credentials. Tried resetting the password it got updated but still not bale to login getting unauthorized error.

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hi,

Welcome to the community!

Can you share how you reset the password?

 
Ann

update users set
crypted_password=‘100000$t2h8AtNs1AlCHuLobDjHQTn9XppwTIx88UjqUm4s8RsfTuXQHSd/fpFexAnewwPsO6jGFQUv/24DnO55hY6Xew==’,
salt=‘k9x9eN127/3e/hf38iNiKwVfaVk=’,
hash_method=‘PBKDF2’,
reset_password=‘true’,
user_local=‘true’,
active=‘true’
where login=‘admin’;

I used different images like latest ,community build, lts-community but all are giving me same error even after trying to reset the password.

I installed sonarqube using docker-compose .I confirm that the UI is coming but admin/admin is not working.

I tried to search for admin user inside postgres DB i didnt find one. not sure if im looking it correctly.

Please help me with this installation, we are going to use this in production if POC is successful.

Hi,

Without a char-by-char comparison, this looks like the Postgres / SQL Server reset SQL. So let’s back up: are you sure the admin account still exists in the DB?

 
Ann

Hi Ann,

No, i verified with \du command on DB and I see only sonar user is there. So created admin user and ran the update command.

CREATE USER admin WITH PASSWORD ‘admin’ ;

First created admin user and tried login with admin password, it didn’t work. Than ran the update command , then also it didn’t work.

I tried this command as well, but it gave me error like randon-uuid already used

insert into user_roles(uuid, user_uuid, role)
values (‘random-uuid’, (select uuid from users where login=‘mylogin’), ‘admin’);

Hi,

We’re not looking for a login you can use to access the database directly. You should probably delete that user from your database.

Can you provide the exact error you got?

 
Thx,
Ann

I didnt see any errornow but still not able to login. Same authentication failed message on UI.

Hi,

From your screenshot, it seems you ran an UPDATE on a user that didn’t exist yet, since the UPDATE came before the INSERT.

 
Ann

Hi,

No, I ran the INSERT command first in the screenshot then i used UPDATE.

Hi,

Sorry, my mistake.

I’ve just taken a closer look at that screenshot… it seems that you copy/pasted/ran the insert without customizing it, though.

 
Ann

Sorry but I am not sure how to use this command to enable/activate admin user. Can you please help me with that.

Hi,

The docs will get you started.

 
Ann

Yeah i used the same document.

The command is

insert into user_roles(uuid, user_uuid, role)
values (‘random-uuid’, (select uuid from users where login=‘mylogin’), ‘admin’);

I used the same for admin creation/activation.
Can you please let me know what fields i need to update.

Hi,

Did you run it like this^ or sub-in your actual login?

 
Ann

i ran the same command, login=‘mylogin’, do i need to change that ?

Please let me know what i should change. Sorry I am not a DB person so I am not aware of these commands.

Hi,

From the docs I linked above (emphasis mine):

If by mistake, you have no users able to access SonarQube Server with the global ‘Administer system’ permission level, you must re-grant the ‘Administer system’ permission to an existing, active user with the following query (myLogin in the query sample represents the login of the user who should become a system administrator):

In other words, myLogin is just a placeholder for the login of the user in your organization that you want to grant admin rights to.

 
HTH,
Ann

I have only one user “sonar” presently, should i replace mylogin with sonar?

insert into user_roles(uuid, user_uuid, role)
values (‘random-uuid’, (select uuid from users where login=‘sonar’), admin’);

Next shall i run this command as is or any chnages here ?

update users set
crypted_password=‘100000$t2h8AtNs1AlCHuLobDjHQTn9XppwTIx88UjqUm4s8RsfTuXQHSd/fpFexAnewwPsO6jGFQUv/24DnO55hY6Xew==’,
salt=‘k9x9eN127/3e/hf38iNiKwVfaVk=’,
hash_method=‘PBKDF2’,
reset_password=‘true’,
user_local=‘true’,
active=‘true’
where login=‘admin’;

Hi,

Assuming we’re talking about users in SonarQube Community Build not database users), then yes.

If you have only one user in SonarQube then that where login='admin' needs to say where login='sonar'.

 
HTH,
Ann

Hi,

can you please let me know how to check SonarQube Community users, using which we can login to the UI.

I got bit confused here, are DB users different from sonarqube users ?

I want to know where we can check for sonarqube users who can login to UI and how to reset the admin password if admin/admin credentials are not working.