解决zabbix5.0 caching_sha2_password加密方式报错;
如下是zabbix-server日志内容:
19251:20210719:123011.155 Cannot connect to the database. Exiting...
19276:20210719:123021.413 Starting Zabbix Server. Zabbix 5.0.14 (revision 892ce506db).
19276:20210719:123021.413 ****** Enabled features ******
19276:20210719:123021.413 SNMP monitoring: YES
19276:20210719:123021.413 IPMI monitoring: YES
19276:20210719:123021.413 Web monitoring: YES
19276:20210719:123021.413 VMware monitoring: YES
19276:20210719:123021.413 SMTP authentication: YES
19276:20210719:123021.413 ODBC: YES
19276:20210719:123021.413 SSH support: YES
19276:20210719:123021.413 IPv6 support: YES
19276:20210719:123021.413 TLS support: YES
19276:20210719:123021.413 ******************************
19276:20210719:123021.413 using configuration file: /etc/zabbix/zabbix_server.conf
19276:20210719:123021.417 [Z3001] connection to database 'zabbix' failed: [2059] Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
19276:20210719:123021.417 Cannot connect to the database. Exiting...
问题分析 Client does not support authentication protocol requested by server; consider upgrading MySQL client
注意 : Authentication plugin ‘caching_sha2_password’ cannot be loaded
原因:密码加密方式【caching_sha2_password】,客户端不支持。
这个问题是由于我的mysql更新至8版本以上了,在安装的时候我并没有指定用户登入密码加密方式,所以默认被设置为 caching_sha2_password
解决方法:
1:登录MySQL #这里使用的是MySQL8.0
root@localhost ~]# mysql -uroot -p'Linux112'
mysql: [Warning] Using a password on the command line interface can be insecu
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 61
Server version: 8.0.26 MySQL Community Server - GPL
Copyright (c) 2000, 2021, 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>
2:查看加密方式
mysql> show variables like 'default_authentication_plugin';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+
1 row in set (0.03 sec)
3:查看本地mysql用户的信息
mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | mysql_native_password |
| localhost | zabbix | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)
4:修改zabbix加密方式
mysql> ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root_password';
Query OK, 0 rows affected (0.04 sec)
mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | mysql_native_password |
| localhost | zabbix | mysql_native_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)