- Reset lost admin password of Grafana server (CentOS 7)
- Several typical errors got in attempt to reset the Grafana admin password
- Bonus section – manual reset the password in the database without grafana-cli
- 3 thoughts on “Reset lost admin password of Grafana server (CentOS 7)”
- Leave a Reply Cancel reply
- Find Us
- About This Site
- Графана Восстановление пароля
- Графана Восстановление пароля
- Что такое Графана?
- Учебник Grafana:
- Учебник — Восстановление пароля Grafana
- Grafana Dashboard Войти
- Grafana default username and password is incorrect #185
- Comments
- ronnyandre commented May 14, 2020
- Slyke commented May 14, 2020
- ronnyandre commented May 14, 2020
- Paraphraser commented May 14, 2020
- Paraphraser commented May 14, 2020
- Paraphraser commented May 14, 2020
- Paraphraser commented May 14, 2020
- Install and Start Grafana
- Video Lecture
- Description
- Updating Grafana
- Downgrading Grafana
- Reset Password
Reset lost admin password of Grafana server (CentOS 7)
It could happen to lose your Grafana admin password and luckily there is a pretty easy way for the system administrator of the Grafana server to reset the admin password.
There is really good and simple page of how you can reset the admin password with grafana-cli in the documentation of Grafana website. Probably you can check it, too.
The problem is that most distributions like the one we use (CentOS 7) rearrange the home directory of the Grafana software and if you try to use grafana-cli you’ll end up with the error mentioned in the section below the solution we offer you here! And you really could mess it up and hurry to say this software is buggy!
First, “grafana-cli admin reset-admin-password ” needs to know where is your configuration file and Grafana home directory, because from the configuration it will extract what kind of back-end server you use like sqlite3 or MySQL (or other) and the path or login data if needed to the back-end, then it will reset the password with the given one. At the bottom of this article, there is another method of resetting the Grafana admin password without grafana-cli – manual reset in the database.
So first you should check with what command-line arguments was your instance of Grafana server started:
It appeared that Grafana server in CentOS 7 has the config in “/etc/grafana/grafana.ini”, plugins and sessions are in “/var/lib/grafana”, logs in “/var/log/” and the home directory as of grafana-cli expect to be is in “/usr/share/grafana” (look below to see why you cannot use this directory for proper resetting of the admin password). So you should pass 2 additional arguments to be sure “grafana-cli admin” will reset the admin password in the right place:
So you MUST see just 2-3 lines above, nothing more! Just output saying the tool connection to the database and then successful reset.
This is the most common pitfall different Linux distros just change the directory scheme of the configuration and data files of the software and you might have real problems when you try to run it with the default values (those set by the developer)!
Several typical errors got in attempt to reset the Grafana admin password
Using grafana-cli with the default values for all configuration and data files:
OR you can try with just a home directory:
Or even you could try the home path in the link above “–homepath “/usr/share/grafana” and at first you might think it was a successful reset but it wasn’t, you just created a new grafana.db file and you should not do this! Of course, you still cannot log in, because the password is invalid! If you see the output below you DID not reset your password for sure!
And after you created the database file for the password in the wrong place all of the future execution of changing the password will modify this wrongly created file and your password will not work and you’ll still get the invalid password or name.
Bonus section – manual reset the password in the database without grafana-cli
First you should find your Grafana configuration file, under CentOS 7 it is in “/etc/grafana/grafana.ini”:
Open the file and look for lines like:
As you can see this configuration says the type of the database is “sqlite3” and the file of the database is in /var/lib/grafana – /var/lib/grafana/grafana.db. So execute the following to reset the password:
3 thoughts on “Reset lost admin password of Grafana server (CentOS 7)”
The cli reset didn’t work as it said that admin was not a valid option.
Tried the sqlite method which worked.
Many thanks for the post.
Tried the sqlite method which worked, thanks A LOT !
the SQLite method work for me
Leave a Reply Cancel reply
Find Us
Address
101010010100 Main Street
Earth, EA 101010101010100
E-mail
info@ahelpme.com
Hours (in the TimeBank)
1000000:00:0:00:00 in time…
About This Site
Highly skilled hominins inhabited planet Earth a long long ago! And these hominins have a need to share some knowledge here.
Графана Восстановление пароля
Графана Восстановление пароля
Хотите узнать, как восстановить пароль администратора Grafana? В этом руководстве мы покажем вам, как использовать процедуру восстановления пароля Grafana для изменения пароля пользователя с правами администратора с помощью командной строки компьютера, на котором работает Ubuntu Linux.
• Ubuntu 18.04
• Ubuntu 19.04
• Графана 6.0.2
Что такое Графана?
Grafana — это платформа с открытым исходным кодом для мониторинга, анализа и визуализации данных, которая поставляется с веб-сервером, позволяющим получать к нему доступ из любого места.
В веб-интерфейсе пользователи могут создавать информационные панели Grafana с панелями для представления метрик с течением времени.
Учебник Grafana:
На этой странице мы предлагаем быстрый доступ к списку уроков Grafana.
Учебник — Восстановление пароля Grafana
В нашем примере мы используем MySQL в качестве службы базы данных для Grafana.
Во-первых, нам нужно получить доступ к серверу MySQL от имени пользователя root.
Используйте следующую команду для установки необходимых пакетов.
# apt-get update
# apt-get install mysql-client
Используйте следующую команду для входа на сервер MySQL от имени пользователя root.
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17226
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
Система попросит вас ввести пароль пользователя MySQL root.
После ввода пароля используйте следующие команды MySQL для сброса пароля пользователя Grafana Admin.
В нашем примере мы изменили пароль пользователя admin на admin.
Grafana Dashboard Войти
Откройте браузер и введите IP-адрес вашего сервера плюс: 3000.
В нашем примере в браузере был введен следующий URL:
Веб-интерфейс Grafana должен быть представлен.
На экране подсказки введите данные для входа в Пароль Grafana по умолчанию.
• Имя пользователя: admin
• Пароль: админ
Система попросит вас изменить пароль Grafana по умолчанию.
После успешного входа в систему будет отображаться панель управления Grafana.
Поздравляем! Вы успешно восстановили пароль пользователя Grafana Admin.
Grafana default username and password is incorrect #185
Comments
ronnyandre commented May 14, 2020
I did a fresh install of Grafana, but I am not able to log into Grafana, even though the default username and password is both set to «admin».
Reset password does not work as IOTstack does not have an email service.
The text was updated successfully, but these errors were encountered:
Slyke commented May 14, 2020
But to answer your question, go into the grafana.env file and uncomment the lines that set the username and password if you haven’t already tried. The env file will be in the /services/grafana/ directory, don’t use the one in /.templates/grafana unless you plan to rebuild.
ronnyandre commented May 14, 2020
I did set the username and password, and then ran docker-compose up -d . Still no luck.
Paraphraser commented May 14, 2020
I have not hit a problem like this with Grafana but I did run into a problem in PiHole that sounds quite like this one. I explained what I had found in #73. Look for the comment starting with “I will tell you something else that is also quite intriguing. ”. I can’t promise it will help but it may give some clues.
I also recall running into a problem with passing settings to InfluxDB which, now that I think about it, may be another example of the same problem. I am not sure whether I ever documented it in an issue. I’ll keep looking and add to this if I find it.
Paraphraser commented May 14, 2020
I found what I was thinking of. It was a Discord reply but it turned out to be unrelated.
Paraphraser commented May 14, 2020
This is the magic incantation:
By the way, my grafana.env has always had:
In other words, those have always been commented-out. The first time I fired up Grafana from the web interface, it wanted “admin/admin” then prompted me to change the password.
I just reset the password to “admin” as explained above. I did not restart the container. I just reconnected to Grafana’s web UI and it took me through the same forced password change.
I suppose that it is possible that, if I had (1) reset the password to admin, (2) stopped the container (stop, not restart), (3) set a specific password in the environment file then (4) run “docker-compose up -d” to bring Grafana up again, then that password from the environment file might have been used. But I did not test that. It seems fairly obvious from the behaviour of the reset command that the password is stored in an SQLite database. Even if the environment file method works, I think it will only ever be a one-shot. It will never be a general method for password maintenance.
Paraphraser commented May 14, 2020
Oh, the most likely reason why a fresh install did not work for you is because the password is almost certainly stored in “
/IOTstack/volumes/grafana/data/grafana.db”. You’d have to blow that away to get a truly clean install.
I was recently trying a full restore of a daily backup from my “live” RPi4 onto a “test” RPi4 and my Grafana password came along for the ride. I was surprised and pleased. The full restore actually worked really well. The only tricky bit was Influx. Every other container just fired up.
In fact, I confused the hell out of myself when I started seeing “live” data appear in the Influx databases on the test machine. I thought, “how can that be? All my Arduinos are logging to the live machine and don’t know about the test machine.” It turned out that instead of my Node-Red flows subscribing to “mosquitto” (as a host name on the Docker bridged network) I was using the fully qualified domain name of the live machine. So it was Node-Red on the test machine that had subscribed to the broker on the live machine. I felt like a twit when I finally figured it out but it certainly proved that restoring an IOTstack backup actually works. Works really well!
Install and Start Grafana
Video Lecture
Description
Grafana is the analytics platform for all your metrics. Grafana allows you to query, visualize, alert on and understand your metrics no matter where they are stored.
In this lecture, I will manually install Grafana on an Ubuntu 20.04, and then start it.
In this course all my examples are executed on an unrestricted Ubuntu 20. You can get minimal Ubuntu 20 server from cloud providers. In this course I used Digital Ocean, with this link https://m.do.co/c/23d277be9014. You will get $50 credit for 30 days for new registrations, where you can create and delete as many VMs as you wish up to the credit limit without any charge. The minimal $5 a month Ubuntu 18 Droplet is what I used for all the examples in the course.
Other providers are Hetzner Cloud, AWS, Azure, GCP and many more. Each solution will have there own requirements that you will need to overcome especially with giving your server network access and sufficient permissions.
You can also use a Oracle Virtual Box with an Ubuntu VM, Docker, Kubernetes, Vagrant, etc. They all have there specific complications. If you are not proficient in your chosen platform that you install your server on, you will have issues.
Keep it simple and use the Digital Ocean or Hetzners links I provided so that you can follow all the examples in the course with minimal issues.
If you use Centos, you may have more specific issues with SELINUX that you will need to overcome.
After the course, once you are familiar with Grafana, then you should install it on your chosen environment so that you know whether your problem is related to Grafana, or your chosen environment.
With a new install of your operating system, I am using Ubuntu 20.04 LTS, we should SSH onto our new server.
On Windows we can use Putty as our SSH client. SSH means ‘Secure Shell’.
Download and Install Putty, and add your server ip address to the Session configuration page.
Once you have connected, on Ubuntu, make sure your package lists are updated.