Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: grafana密码忘了,如何恢复默认密码admin
Here is my solution. If there are other methods, please advise.
- Check the Grafana deployment path.
- Switch to the data directory.
cd /data/tidb-deploy/grafana-3000/
- Modify the command:
Enter the database
sqlite3 grafana.db
Change the password
update user set password = ‘59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6’, salt = ‘F3FAxVm33R’ where login = ‘admin’;
Exit
.exit
If the prompt “Admin password changed successfully
” appears, it means it is already okay.
To restore Grafana’s default password admin
, you can follow these steps:
Method 1: Reset User Password
- Stop Grafana Service:
- For Linux systems, use the following command to stop the Grafana service:
sudo systemctl stop grafana-server
- For Windows systems, open the Service Manager, find the Grafana service, and stop it.
- Edit Grafana Database:
- Locate Grafana’s SQLite database file, usually found at
/var/lib/grafana/grafana.db
.
- Use the SQLite3 tool to open the database file:
sqlite3 /var/lib/grafana/grafana.db
- Run the following SQL command to reset the password:
UPDATE user SET password = '5f4dcc3b5aa765d61d8327deb882cf99' WHERE login = 'admin';
5f4dcc3b5aa765d61d8327deb882cf99
is the MD5 hash value for admin
.
- Restart Grafana Service:
- For Linux systems, use the following command to restart the Grafana service:
sudo systemctl start grafana-server
- For Windows systems, open the Service Manager, find the Grafana service, and start it.
- Log in to Grafana:
- Open your browser and go to the Grafana login page.
- Log in with the default username
admin
and password admin
.
- The system will prompt you to change the password; follow the instructions.
Method 2: Modify Configuration File
- Edit Grafana Configuration File:
- Locate and edit the Grafana configuration file
/etc/grafana/grafana.ini
.
- Add or modify the following content under the
[security]
section:
[security]
admin_user = admin
admin_password = admin
- Restart Grafana Service:
- For Linux systems, use the following command to restart the Grafana service:
sudo systemctl restart grafana-server
- For Windows systems, open the Service Manager, find the Grafana service, and restart it.
- Log in to Grafana:
- Open your browser and go to the Grafana login page.
- Log in with the default username
admin
and password admin
.
- The system will prompt you to change the password; follow the instructions.
Both methods can help you restore Grafana’s default password. If you have any questions or need further assistance, please let me know.
Execute grafana-cli admin reset-admin-password <new password>
and then restart Grafana.
Scale down and then scale up again, anyway, there’s no data in Grafana.
I encountered this problem before and it was quite tricky. We were even ready to scale down, but other colleagues had saved the password, so we didn’t go that route. It turns out you can reset it through a command. Marking this down~! grafana-cli admin reset-admin-password
You can try resetting the password. I have tried it before, and the operation is quite simple.
grafana reset password
What should I do if there is a vulnerability in Grafana?
If it reaches that point, it means physical security can’t be guaranteed, so there’s no need to worry about any data leaks. 