一、需要连接到zabbix的mysql的数据库。
1.如果忘记mysql的密码可以通过以下命令进行查询到zabbix的配置文件在配置文件内查看。
find / -name zabbix_server.conf
[root@zabbix-server ~]# find / -name zabbix_server.conf
/etc/zabbix/zabbix_server.conf
查看配置文件找到DBPassword=XXXXXX 这里的XXXXX就是数据库的密码
[root@zabbix-server ~]# cat /etc/zabbix/zabbix_server.conf
.............
.............
### Option: DBSchema
# Schema name. Used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBSchema=
### Option: DBUser
# Database user.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=zabbix
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=Qianfeng@123
..............
..............
..............
2.登录到数据库内
[root@zabbix-server ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 806
Server version: 5.7.42 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
3.修改zabbix的登录密码,具体如下
>select user(); 查看当前用户
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| zabbix |
+--------------------+
5 rows in set (0.01 sec)
mysql> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from users; 查看admin账户名,可能是admin也可能是Admin
+--------+-------+--------+---------------+--------------------------------------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+--------------+---------------+---------------+
| userid | alias | name | surname | passwd | url | autologin | autologout | lang | refresh | type | theme | attempt_failed | attempt_ip | attempt_clock | rows_per_page |
+--------+-------+--------+---------------+--------------------------------------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+--------------+---------------+---------------+
| 1 | Admin | Zabbix | Administrator | $2y$10$QRkPJLYYJsQ20skG1UQOSeDZjYPCb3a.MUpSTMGL6zUKvGUAZrWDa | | 1 | 0 | zh_CN | 30s | 3 | default | 2 | 192.168.46.1 | 1700487686 | 50 |
| 2 | guest | | | $2y$10$89otZrRNmde97rIyzclecuk6LwKAsHN0BcvoOKGjbT.BwMBfm7G06 | | 0 | 15m | en_GB | 30s | 1 | default | 0 | | 0 | 50 |
+--------+-------+--------+---------------+--------------------------------------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+--------------+---------------+---------------+
2 rows in set (0.00 sec)
>UPDATE user SET password=PASSWORD('新密码') WHERE user='用户';
例如: update users set passwd= md5('zabbix') where alias='Admin';
mysql> flush privileges; 刷新一下
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye