Grafana: Reset Admin pass

Created on 20 Apr 2015  ·  26Comments  ·  Source: grafana/grafana

I was changing my pass! But now, the new Password isnt working! How can i reset it?

efformedium help wanted

Most helpful comment

+1

With SQLite on Ubuntu I had to do this:

$ sudo sqlite3 /var/lib/grafana/grafana.db

sqlite> update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';
sqlite> .exit

All 26 comments

yea, this feature is not yet implemented :(

what database do you use for grafana? Sqlite ? I can walk you trough or give you a script that resets it

@torkelo yes im using sqlite!

i am using mysql, any chance you can post the instructions here.

Need admin password reset for postgres.

Update the password and salt columns in the user table:
update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin'

if its mysql you need to escape user, like user

The above will set password back go admin/admin

Thanks.

user table needs to be in quotes for postgres ie: update "user" set ...

+1

With SQLite on Ubuntu I had to do this:

$ sudo sqlite3 /var/lib/grafana/grafana.db

sqlite> update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';
sqlite> .exit

I tried the given solution, and when I logged in with admin user after a little while (less than a minute) it kicked me out to login page. Now I can not login and when I set password again it does not have any effect.

UPDATE: just checked the database, user was deleted for some reason I don't know. I'm not sure how to create new admin user. Should I open another issue?

@torkelo apologies for opening up an old thread. Can you tell me what type of hash value grafana uses and how you would create a salt value? I'm new to password hashing in general and wish to automate the creation of grafana users via mysql within my Puppet setup.

Any info you can provide would be appreciated.

Cheers,
L.

@Qtax .. this is great trick.

  1. stop grafana
  2. setup admin user and password in grafana.ini
  3. delete /var/lib/grafana/grafana.db
  4. restart

I did reset password this way, but all previous dashboard data is lost.

Which hashing algorithm do you use, how to generate some other password?
thanks.

@miodrag-zivkovic-shiftplanning We use PBKDF2 from this golang package. For login, we also have a guard for time based attacks.

What do you mean by

how to generate some other password?

why grafana-cli admin reset-admin-password admin docments not working? It's told me
Admin password changed successfully ✔
thanks for Qtax

@eoekun So you changed the password but it still does not work (with username admin)?

EDIT: nevermind, I see you did it via the database instead.

@daniellee Use the grafana-cli does not work so I execute the sql statement.

http://docs.grafana.org/administration/cli/#reset-admin-password

@eoekun what version are you running? grafana-cli-admin reset-admin-password works fine for me in 4.5.2

Just for anyone may need this - my grafana docker installation suddenly reseted user table and I was able to login only with default admin:admin pair.
grafana-cli admin reset-admin-password admin was not working just because of empty user table.

  1. edit /etc/grafana/grafana.ini
    set admin_user and admin_password in the [security] section
  2. stop the grafana service
  3. delete the admin user from the db:
    # sqlite3 /var/lib/grafana/grafana.db
    sqlite> delete from user where login = 'admin';
  4. start the grafana service
  5. login with the admin user/pass you put in /etc/grafana/grafana.ini

My user table (in /usr/share/grafana/data/grafana.db) has the admin user, and I've verified that the admin user row updates when using the sudo grafana-cli admin reset-admin-password newPassword command (while in /usr/share/grafana). Yet this does not allow you to log in with the new password.

Not only do the official instructions on the support page (http://docs.grafana.org/administration/cli/) not work, the instructions telling you to manually modify the SQLite3 database at /var/lib/grafana/grafana.db don't tell you that the password will be admin afterwards.

Your documentation should make clear that the relevant database is /var/lib/grafana/grafana.db, not /usr/share/grafana/data/grafana.db, and more importantly, you should make it possible to use the grafana-cli admin reset-admin-password against the real database. It is unreasonable to expect people to manually modify a hashed password and its salt in the database.

Team, We are running grafana in kubernetes container. I forgot the admin password and try to reset the password with below command. but no luck.
grafana-cli admin reset-admin-password --homepath "/usr/share/grafana" newpass

Can you please suggest how to i reset the admin@localhost/admin password on grafana container

This is broken due to the service graph refactoring.

The cli does not init the transaction manager and the bus itself.

1. edit `/etc/grafana/grafana.ini`
   set `admin_user` and `admin_password` in the `[security]` section

2. stop the grafana service

3. delete the admin user from the db:
   `# sqlite3 /var/lib/grafana/grafana.db`
   `sqlite> delete from user where login = 'admin';`

4. start the grafana service

5. login with the admin user/pass you put in `/etc/grafana/grafana.ini`

Worked for me thanks using v5.3.4 in a lxd container!

@xdfil's solution worked for me but only after deleting ALL users, not just admin.

Was this page helpful?
0 / 5 - 0 ratings