I am using grafana version 9.1.3 on my local machine for learning purposes, I didn’t open grafana since a week. Now when i am opening grafana it’s asking for login password, i did not change credentials but when i am entering the default admin, admin it is showing invalid. I am trying to reset passowrd through mail. but i think i didnt link my mail so not getting any link to reset. is there any way where i can get my all previously created dashboards back and can login in old account?
Hi @garimachouhan,
If you are using Grafana OSS or Grafana Enterprise you can run reset admin password via CLI.
grafana-cli admin reset-admin-password <new password>
If you are using Grafana in Cloud you should send a ticket to Grafana team.
If you are not Grafana Administrator then you should as your admin to reset password for your account:
If you have not lost the admin password, we recommend that you change the user password either in the User Preferences or in the Server Admin > User tab.
Best regards,
ldrascic
Same issues facing in my system, I also change password using CLI but it’s show me successfully changed Admin password but when I tried to login with same credential it’s not working.
Thanks in advance.
Riddhi
@codi639 several people have reported the CLI doesn’t work, and the approach you’re taking is fine and can work - but can you report what the error was, why the CLI didn’t work? I’d like to look into making sure the CLI is the easiest/simple way to do this
Hey @davidallen5,
I actually have no idea why it does not work.
I had the same issue as them and find this solution on the topic, so I’m sharing it to make them save time…
The error I actually got is:
root@TIG:~# grafana-cli admin reset-admin-password admin
INFO [08-05|12:16:06] Starting Grafana logger=settings version= commit= branch= compiled=1970-01-01T01:00:00+01:00
INFO [08-05|12:16:06] Config loaded from logger=settings file=/usr/share/grafana/conf/defaults.ini
INFO [08-05|12:16:06] Config loaded from logger=settings file=/etc/grafana/grafana.ini
INFO [08-05|12:16:06] Config overridden from command line logger=settings arg="default.paths.data=/var/lib/grafana"
INFO [08-05|12:16:06] Config overridden from command line logger=settings arg="default.paths.logs=/var/log/grafana"
INFO [08-05|12:16:06] Config overridden from command line logger=settings arg="default.paths.plugins=/var/lib/grafana/plugins"
INFO [08-05|12:16:06] Config overridden from command line logger=settings arg="default.paths.provisioning=/etc/grafana/provisioning"
INFO [08-05|12:16:06] Target logger=settings target=[all]
INFO [08-05|12:16:06] Path Home logger=settings path=/usr/share/grafana
INFO [08-05|12:16:06] Path Data logger=settings path=/var/lib/grafana
INFO [08-05|12:16:06] Path Logs logger=settings path=/var/log/grafana
INFO [08-05|12:16:06] Path Plugins logger=settings path=/var/lib/grafana/plugins
INFO [08-05|12:16:06] Path Provisioning logger=settings path=/etc/grafana/provisioning
INFO [08-05|12:16:06] App mode production logger=settings
INFO [08-05|12:16:06] Connecting to DB logger=sqlstore dbtype=sqlite3
INFO [08-05|12:16:06] Starting DB migrations logger=migrator
INFO [08-05|12:16:06] migrations completed logger=migrator performed=0 skipped=526 duration=800.54µs
INFO [08-05|12:16:06] Envelope encryption state logger=secrets enabled=true current provider=secretKey.v1
Error: ✗ could not read user from database. Error: user not found
Which is kinda strange since there’s users in the .db file:
sqlite> select * from user;
3|0|admin|admin@localhost||59acf18b94d7e.....aa88a8a6|F3....3R|pz....io||1|1|0||2024-01-15 10:40:51|2024-02-12 08:04:36|1|2024-08-05 10:12:58|0|0
4|0|sa-adding-a-var|sa-adding-a-var|adding a var||g5....OK|b2....ah||1|0|0||2024-07-10 07:52:32|2024-07-10 07:52:32|0|2024-07-10 13:30:54|0|1
hey @davidallen5
I got it now!
Reading the source-code of Grafana leads me to get something very simple.
By default, the command try to run on user-id 0 if no user-id
provided. I might be wrong concerning the default user-id value code since I’ve never do Go, but there’s still a default value. In my case, and I think for others people with this issue too, the admin user isn’t in user-id 0 (or the good default value) anymore, which leads to a no user found
and that’s logical.
How to make it work:
grafana-cli --homepath "/usr/share/grafana/" -debug admin reset-admin-password --user-id 3 admin
- The homepath is needed only if you’re not in the installation directory.
- Change
3
by your actual adminuser-id
- you can find it on the grafana.db, often located
/var/lib/grafana/grafana.db
select * from user where login='admin';
- you can find it on the grafana.db, often located
Could it be possible to change the resetPasswordCommand(c utils.CommandLine, runner server.Runner)
function to make it handle different admin user-id
?
thanks for posting this. I’m following up with our internal engineering teams to have them take a look at this and see if they can find what’s up and how to fix more systematically.