April 2021 Update:
1 | docker exec pmm-server change-admin-password <new_password> |
If you’re automating Percona Monitoring and Management 2 (PMM) deployment with docker, you may want to set a different admin user password upon installation instead of being required to change it upon first login. Here is how you can do it.
After following the PMM2 Docker Installation Instructions, you can run this command:
1 | docker exec -t pmm-server bash -c 'grafana-cli --homepath /usr/share/grafana --configOverrides cfg:default.paths.data=/srv/grafana admin reset-admin-password newpass' |
Where “newpass” is your new desired password and “pmm-server” is the container name you used to deploy PMM, you should see the following output indicating the password was changed successfully:
1 2 3 4 | INFO[01-05|22:01:15] Connecting to DB logger=sqlstore dbtype=sqlite3 INFO[01-05|22:01:15] Starting DB migration logger=migrator Admin password changed successfully ✔ |
That’s it!
Great tips to avoid using the default password for the whole system. Unfortunately when trying to use this command with an Ansible task, we are not indempotent anymore (The task is always executed for all playbook runs).
Is there a way to compare the password we want to apply before applying the docker exec command ?
I have found this method is no longer reliable, and have had to resort to the sqlite method. It seems the new grafana update has made such things more difficult.
sqlite3 /srv/grafana/grafana.db
update user set password = ’59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6′, salt = ‘F3FAxVm33R’ where login = ‘admin’;
Im trying to reset the password to a complex one with the help of this [blog|https://www.percona.com/blog/2020/01/15/changing-the-default-admin-password-in-docker-based-deployment-of-pmm2/.]
docker exec -t pmm-server bash -c 'ln -s /srv/grafana /usr/share/grafana/data; grafana-cli --homepath /usr/share/grafana admin reset-admin-password Li85dJ2e'
Then I did a restart, but it didn’t work.
But when use
admin
as the new password then it worked.One more try:
Reset the admin password as admin, then if you login it’ll ask to change the default password, then I have a different password, it worked till that session. When I log out and try to login, its showing invalid password.
Another way:
Login with admin/admin, then go to dashboard –> click on the user avatar –> change password. After logout and login, again, invalid password.
this method does not work now:
docker exec -it angry_edison /usr/bin/grafana-cli -homepath ‘/usr/share/grafana’ admin reset-admin-password ‘c8ZMmQiH0rF302gz’
INFO[01-05|02:28:47] Connecting to DB logger=sqlstore dbtype=sqlite3
INFO[01-05|02:28:47] Starting DB migrations logger=migrator
INFO[01-05|02:28:47] migrations completed logger=migrator performed=0 skipped=279 duration=1.525996ms
Admin password changed successfully ✔
then I go to log in with the new admin password it complains invalid username and password
This is not the command this post suggest to run 🙂 This changes the password in the default Grafana DB which comes with installation not the one PMM actually uses to operate
Ooh Peter! I’m calling you out on having edited the page https://web.archive.org/web/20200226161348/https://www.percona.com/blog/2020/01/15/changing-the-default-admin-password-in-docker-based-deployment-of-pmm2/
It would seem after PMM 2.23 the old command stopped working, indeed the now updated command in the post works in PMM2.25.