操作系统: CentOS release 6.10 (Final)
数据库:MySQL 5.5.55
问题场景:当忘记zabbix管理员密码时,如何重置密码?
操作步骤:
1.进入zabbix数据库
[sky9890@sky9890 ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 58218
Server version: 5.5.55 MySQL Community Server (GPL) by Atomicorp
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
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>
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>
2.查看user表
mysql> desc users;
+----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+-------+
| userid | bigint(20) unsigned | NO | PRI | NULL | |
| alias | varchar(100) | NO | UNI | | |
| name | varchar(100) | NO | | | |
| surname | varchar(100) | NO | | | |
| passwd | char(32) | NO | | | |
| url | varchar(255) | NO | | | |
| autologin | int(11) | NO | | 0 | |
| autologout | varchar(32) | NO | | 15m | |
| lang | varchar(5) | NO | | en_GB | |
| refresh | varchar(32) | NO | | 30s | |
| type | int(11) | NO | | 1 | |
| theme | varchar(128) | NO | | default | |
| attempt_failed | int(11) | NO | | 0 | |
| attempt_ip | varchar(39) | NO | | | |
| attempt_clock | int(11) | NO | | 0 | |
| rows_per_page | int(11) | NO | | 50 | |
+----------------+---------------------+------+-----+---------+-------+
16 rows in set (0.00 sec)
mysql> select userid,name,passwd from users;
+--------+--------+----------------------------------+
| userid | name | passwd |
+--------+--------+----------------------------------+
| 1 | Zabbix | 3a57ecc*************bdd48c2a25 |
| 2 || d41d8cd98f00b204e9800998ecf8427e |
+--------+--------+----------------------------------+
2 rows in set (0.00 sec)
3.修改密码
mysql> update users set passwd=MD5('***') where userid=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select userid,alias,passwd from users;
+--------+-------+----------------------------------+
| userid | alias | passwd |
+--------+-------+----------------------------------+
| 1 | admin | b464c56*************52c48a68324c254 |
| 2 | guest | d41d8cd98f00b204e9800998ecf8427e |
+--------+-------+----------------------------------+
2 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4.注意事项:
修改密码后,原先的zabbix用户名自动变更为admin用户名了。