最新部署的一台zabbix server使用的Percona TokuDB引擎(Percona Server for MySQL 8.x),该主机在进行数据库接时报错:Authentication plugin ‘caching_sha2_password’ cannot be loaded。网上查了下问题原因,MySQL8.0.11版本默认的认证方式是caching_sha2_password ,而在MySQL5.7版本则为mysql_native_password。需要使用mysql_native_password密码进行连接。

解决方式1:

修改全局配置使用mysql_native_password认证方式,需要修改my.cnf文件,并重启服务生效(此参数不可动态修改,无法mysql> set global default_authentication_plugin=’mysql_native_password’修改)

1vim my.cnf
2[mysqld]
3default_authentication_plugin=mysql_native_password

解决方式2:

兼容新老版本的认证方式,创建不同的帐户分别使用不同的认证方式,对于不支持的client,还使用老的方式。

1ALTER USER 'root'@'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER; #修改加密规则
2ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; #更新一下用户的密码
3FLUSH PRIVILEGES; #刷新权限

查看不同的用户对应的认证方式如下:

 1mysql> show variables like 'default_authentication_plugin';
 2+-------------------------------+-----------------------+
 3| Variable_name                 | Value                 |
 4+-------------------------------+-----------------------+
 5| default_authentication_plugin | caching_sha2_password |
 6+-------------------------------+-----------------------+
 71 row in set (0.01 sec)
 8mysql> select host,user,plugin from mysql.user;
 9+-----------+------------------+-----------------------+
10| host      | user             | plugin                |
11+-----------+------------------+-----------------------+
12| %         | root             | caching_sha2_password |
13| localhost | mysql.infoschema | mysql_native_password |
14| localhost | mysql.session    | mysql_native_password |
15| localhost | mysql.sys        | mysql_native_password |
16| localhost | root             | caching_sha2_password |
17+-----------+------------------+-----------------------+

最后再记录一点关于Percona Server for MySQL安装相关的内容,这个包下载比较慢,可以只下载以下部分包就可以了。debug和test部分包不需要下载,官方下载地址为:https://www.percona.com/downloads/Percona-Server-LATEST/

percona-mysql-router-8.0.19-10.1.el7.x86_64.rpm
percona-server-client-8.0.19-10.1.el7.x86_64.rpm
percona-server-devel-8.0.19-10.1.el7.x86_64.rpm
percona-server-rocksdb-8.0.19-10.1.el7.x86_64.rpm
percona-server-server-8.0.19-10.1.el7.x86_64.rpm
percona-server-shared-8.0.19-10.1.el7.x86_64.rpm
percona-server-shared-compat-8.0.19-10.1.el7.x86_64.rpm
percona-server-tokudb-8.0.19-10.1.el7.x86_64.rpm

为了加速下载,找了下国内源,发现清华源有,不过里面的版本更新不及时,里面目前看到的还是5.5版本的,地址为:https://mirrors.tuna.tsinghua.edu.cn/percona/percona/yum/release/latest/os/x86_64/

这里我测试了下使用ps-admin方式没找到相关指令,最后使用了手动的方式进行安装,操作方式如下:

1INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';
2INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';
3INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';
4INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';
5INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';
6INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';
7INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';
8INSTALL PLUGIN tokudb_background_job_status SONAME 'ha_tokudb.so';

安装完成后可以通过SHOW ENGINES和SHOW PLUGINS指令进行确认。