If you happen to have lost the admin password of your grafana server and have issues logging in after many tries then you have come to the right place. Here we will go over how you can reset the grafana admin password to the default login. The default admin password for grafana is admin
This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has
sudoaccess and that you precede each of the privileged commands withsudo
One way to reset grafana admin password is via the grafana cli
First we need to know where grafana homepath is and where the configuration file is located. To do this we need to check the grafana process to see these information
root@codesposts:~# pa aux | grep grafana
grafana 312 0.0 0.0 2144576 21385 ? Ssl 11:22 1:04 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid cfg:default.paths.logs=/var/log/grafana cfg:default.paths.data=/var/lib/grafana cfg:default.paths.plugins=/var/lib/grafana/plugins cfg:default.paths.provisioning=/etc/grafana/provisioning From the above we can see that grafana is currently running and the configuration file location is /etc/grafana/grafana.ini and the homepath is expected to be located in /usr/share/grafana
Then we can now use the grafana cli command to reset the admin password for granafa
root@codesposts:~# grafana-cli admin reset-admin-password --homepath "/usr/share/grafana" --config "/etc/grafana/grafana.ini" admin
INFO[07-05|01:20:52] Connecting to DB logger=sqlstore dbtype=sqlite3
INFO[07-05|01:20:52] Starting DB migration logger=migrator
Admin password changed successfully ✔ You will see from the above output that the admin password has now been successfully reset.
Now you can go to the grafana login url and be able to log in with
username: adminpassword: admin
Another option is to reset the admin password manually from the grafana database which is by default sqlite3.
First we check the configuration file and search for the database being used
... ... #################################### Paths #################################### [paths] # Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) ;data = /var/lib/grafana ... ... ... #################################### Database #################################### [database] # You can configure the database connection by specifying type, host, name, user and password # as separate properties or as on string using the url properties. # Either "mysql", "postgres" or "sqlite3", it's your choice ;type = sqlite3 ;host = 127.0.0.1:3306 ;name = grafana ;user = root # If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;""" ;password = # Use either URL or the previous fields to configure the database # Example: mysql://user:secret@host:port/database ;url = # For "postgres" only, either "disable", "require" or "verify-full" ;ssl_mode = disable # For "sqlite3" only, path relative to data_path setting ;path = grafana.db ... ... ... |
From above we can see that the database used is sqlite3 and the database file is located at /var/lib/grafana/grafana.db
Now we connect to sqlite3 and reset the admin password manually using the sqlite3 client
root@codesposts:~# sqlite3 /var/lib/grafana/grafana.db
SQLite version 3.28.0 2019-07-04 01:12:19
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
alert dashboard_version quota
alert_notification data_source session
annotation login_attempt star
annotation_tag migration_log tag
api_key org team
dashboard org_user team_member
dashboard_acl playlist temp_user
dashboard_provisioning playlist_item test_data
dashboard_snapshot plugin_setting user
dashboard_tag preferences user_auth
sqlite> update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';
sqlite> .exit Now you can go to the grafana login url and be able to log in with
username: adminpassword: admin
The post How To Reset Lost Admin Password For Grafana appeared first on CODESPOSTS.COM.
Go to Source
Author: staff
Open source has come a long way. Recently I was watching a keynote address by…
Sylva 1.5 becomes the first release to include Kubernetes 1.32, bringing the latest open source…
Expansion ensures business continuity without forcing major upgrades Today, Canonical announced the expansion of the…
TL;DR: YARD-Lint catches documentation issues, just like RuboCop for code. Star it and use it…
Deploy a FedRAMP-ready kubernetes cluster and application suite, with FIPS 140-3 crypto and DISA-STIG hardening…
This new release brings the stability and security of Ubuntu to Axion-based N4A virtual machines…