Resetting Grafana Admin Password Using SQLite and grafana-cli
This guide demonstrates two methods to reset the Grafana admin password: directly editing the SQLite database file with SQL commands and using the grafana-cli tool, including all required shell commands and screenshots.
Method 1: Directly edit the SQLite database
Navigate to the Grafana data directory and list its contents:
[root@bogon data]# pwd
/soft/grafana-7.3.5/data
[root@bogon data]# ll
total 656
-rw-r----- 1 root root 671744 Aug 9 14:24 grafana.db
drwxr-xr-x 2 root root 25 Aug 9 14:03 log
drwxr-xr-x 2 root root 6 Jul 27 14:51 plugins
drwx------ 2 root root 6 Jul 27 14:51 png
Enter the SQLite console:
[root@bogon data]# sqlite3 grafana.db
SQLite version 3.7.17 is displayed. List the tables:
sqlite> .tables
Query the user table to view the current admin record:
sqlite> select * from user;
Result (truncated):
1|0|admin|admin@localhost||602a71e2e0c6...|m4FqPuCQkb|CwVtk9Lq67||1|1|0||2021-07-27 06:51:53|2021-07-27 06:52:48|1|2021-07-28 07:28:53|0
Update the password and salt fields (replace with your own hash and salt):
sqlite> update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';
Exit SQLite and start the Grafana server to apply the change:
[root@bogon data]# cd ../bin/
[root@bogon bin]# ll
-rwxr-xr-x 1 root root 25691376 Dec 10 2020 grafana-cli
-rw-r--r-- 1 root root 33 Dec 10 2020 grafana-cli.md5
-rwxr-xr-x 1 root root 59444376 Dec 10 2020 grafana-server
-rw-r--r-- 1 root root 33 Dec 10 2020 grafana-server.md5
Run the server:
[root@bogon bin]# ./grafana-server
After the server starts, you can log in with the new password (see screenshot).
Method 2: Use grafana-cli to reset the password
Execute the following command, replacing xxxxx with the desired password:
grafana-cli admin reset-admin-password xxxxx
Screenshot of the command output is shown below.
--- End of tutorial ---
Recommended reading:
Redis advantages and remote client connections
Redis data backup and recovery
Redis Sentinel setup
Redis master‑slave replication
Detailed Redis configuration summary
If you found this useful, please like, follow, or scan the QR code for more content.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.