Server admin is deleted or missing from Grafana account

This problem occurred when super admin (server admin) credentials got deleted when that user left organisation.
Best practice is that super admin privileges has to be transfer to someone with admin role.
in such cases use below command

grafana-cli --homepath “/usr/share/grafana” admin reset-admin-password

if this not works or it may give error that could not read user from database so in that situation only we have to run below command. Make sure you have stopped Grafana server by

systemctl stop grafana-server

then with root or sudo access use
sqlite3 /var/lib/grafana/grafana.db

then paste below command
INSERT INTO user (id, version, login, email, name, org_id, is_admin, created, updated) VALUES(1, 0, ‘admin’, ‘admin@localhost’, ‘Admin’, 1, 1, datetime(‘now’), datetime(‘now’));

then press ctrl + d to exit from sqlite3

then try to reset password by
grafana-cli --homepath “/usr/share/grafana” admin reset-admin-password

it will show Admin password changed successfully :heavy_check_mark:

then restart grafana server by
systemctl restart grafana-server

Now check on your browser ‘localhost:3000’
use user as admin & password you set

make sure that while doing database changes grafana server has to be stopped else it may not reflect changes in some cases

1 Like