你会不会忘记密码
grafana登录密码突然忘记了,感觉一时半会找不回账号密码怎么办?一般我会把一些数据文件全部删除掉,然后再重新启动,就和新的一样了。但是,遇到很重要的tidb监控看板,如果删除了数据,很多东西都没有了,那么有没有一种好的方法呢?
数据文件grafana.db
找到grafana的数据文件grafana.db
```
find / -name "grafana.db"
ps:默认的安装路径为/var/lib/grafana/grafana.db
```
### 现在使用的方法
```
[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.7.17 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||0e8518c7400b932a85a63d68dcb31e2728896c1f32dd2db4cca641b4ae26b5f80d4edf6c49f0744c776a365b47baa5179ffc|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
```
简洁版
```
#进入数据库
sqlite3 /var/lib/grafana/grafana.db
#查看表
.tables
#查看表中数据
select * from user;
#更改密码为admin
update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';
#退出
.exit
```
#### 重启grafana
```
service grafana-server restart
```