I forgot my password

Grafana login password suddenly forgotten, feeling that I can not find the account password for a while? I usually delete some data files completely, and then restart them as good as new. However, when you encounter a very important TIDB monitoring kanban, if you delete the data, a lot of things are lost, so is there a good way?

Find grafana’s data file grafana.db

find / -name "grafana.db"
ps: The default installation path is /var/lib/grafana/grafana.db
Copy the code

Non-standard methods

rm -f grafana.db

rm -rf png

This deletes all the files, which is not a standard operation.

The method used now

[root@localhost data]# ll
total 4788
-rw-r----- 1 tidb tidb 4894720 Nov 18 17:21 grafana.db
drwx------ 2 tidb tidb    4096 Sep  9 20:01 png
[root@localhost data]# 
[root@localhost data]# 
[root@localhost data]# 
[root@localhost data]# sqlite3 grafana.db 
SQLite version 3.717. 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
alert                     dashboard_tag             server_lock             
alert_notification        dashboard_version         session                 
alert_notification_state  data_source               short_url               
alert_rule_tag            login_attempt             star                    
annotation                migration_log             tag                     
annotation_tag            org                       team                    
api_key                   org_user                  team_member             
cache_data                playlist                  temp_user               
dashboard                 playlist_item             test_data               
dashboard_acl             plugin_setting            user                    
dashboard_provisioning    preferences               user_auth               
dashboard_snapshot        quota                     user_auth_token         
sqlite> select * from user;
1|0|admin|admin@localhost||0e8518c7400b932a85a63d68dcb31e2728896c1f32dd2db4cca641b4ae26b5f80d4edf6c49f0744c776a365b47baa517 9ffc|c6LfXYoaxO|XbuYjq51Qe||1|1|0||2021-09-09 12:01:45|2021-09-09 12:41:58|0|2021-09-13 01:49:30|0
sqlite> update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';
sqlite>.exit
Copy the code
Enter the database sqlite3 /var/lib/grafana/grafana.db /lib/grafana/grafana.dbfromuser; Admin update user set password ='59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin'; # exit. The exitCopy the code

Restart grafana

service grafana-server restart
Copy the code