使用Percona Toolkit的工具连接MySQL 8.x数据库时,会遇到类似”failed: Plugin caching_sha2_password could not be loaded: lib64/mariadb/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory at /usr/bin/pt-show-grants line 1367“这样的错误,如下案例所示:

#pt-find --ctime +2 --engine InnoDB -u monitor --ask-pass 
Enter password: 
DBI connect(';;mysql_read_default_group=client','monitor',...) failed: Plugin caching_sha2_password could not be loaded: lib64/mariadb/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory at /usr/bin/pt-find line 323.

遇到这个错误是因为MySQL 8.0(8.0.4)引入了caching_sha2_password插件并将其作为默认的身份验证插件,而当前Percona Toolkit(Percona Toolkit 3.2.1是当前最新版本)的工具依赖的MySQL驱动程序尚不支持caching_sha2_password这这种身份验证,所以报这个错误。例如pt-find使用的驱动为MySQL driver for Perl (DBD::mysql)(perl-DBD-MySQL)

解决方案:

1:更改用户的密码插件为mysql_native_password

mysql> select user,host ,plugin from mysql.user where user='monitor';
+---------+-----------+-----------------------+
| user    | host      | plugin                |
+---------+-----------+-----------------------+
| monitor | localhost | caching_sha2_password |
+---------+-----------+-----------------------+
1 row in set (0.00 sec)
 
 
mysql> alter user monitor@'localhost' identified  with mysql_native_password by '************';
Query OK, 0 rows affected (0.07 sec)

这种方法就是让MySQL使用mysql_native_password插件认证密码,这些驱动自然支持这种方式连接MySQL数据库。

2:修改MySQL的全局配置

在my.cnf配置文件中设置default_authentication_plugin=mysql_native_password 后重启MySQL数据库实例。这是一种不太安全的做法,按理说只需修改Percona Toolkit的工具使用的账号即可。但是这种方法修改的是MySQL的全局配置。影响范围扩大,不推荐使用

[mysqld]

default_authentication_plugin=mysql_native_password

3:更新驱动

MySQL 8.0.4开始默认使用caching_sha2_password作为身份验证插件. caching_sha2_password和 sha256_password认证插件提供比mysql_native_password插件更安全的密码加密方式 ,并且使用caching_sha2_password的性能比sha256_password更好。如果我们修改用户的密码插件为mysql_native_password,似乎有点开倒车的感觉。其实这个问题也好解决,如果我们想用新的密码验证方式,那么我们可以安装高版本的驱动。这些驱动支持这种方式。

如下所示,当前测试环境,perl-DBD-MySQL模块依赖的类库为/usr/lib64/mysql/libmysqlclient.so.18。在CentOS/RHEL/OL 7上,默认情况下,perl-DBD-MySQL要么链接到旧版本的mariadb-libs(5.5),或链接mysql-community-libs-compat下的类库。

[root@KerryDB ~]# more /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
[root@KerryDB ~]# ldd /usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so | grep  'mysql\|maria'
        libmysqlclient.so.18 => /usr/lib64/mysql/libmysqlclient.so.18 (0x00007f48b0724000)
[root@KerryDB ~]# rpm -qf /usr/lib64/mysql/libmysqlclient.so.18
mysql-community-libs-compat-8.0.18-1.el7.x86_64

此版本(libmysqlclient.so.18)不支持新的身份验证插件。至少需要有libmysqlclient.so.21或libmariadb.so.3 或以上版本的类库才支持caching_sha2_password认证方式。 所以,我可以下载博客Perl & MySQL 8.0中的perl-DBD-MySQL-4.044-1.el7_.x86_64.zip 或perl-DBD-MySQL-4.050-1.el7.x86_64.rpm组件。

https://lefred.be/wp-content/uploads/2019/06/perl-DBD-MySQL-4.044-1.el7_.x86_64.zip

https://lefred.be/wp-content/uploads/2020/08/perl-DBD-MySQL-4.050-1.el7.x86_64.rpm

具体安装过程如下, 安装完成后,Percona Tookkit就能正常连接MySQL 8了

[root@KerryDB tmp]#  rpm -ivh perl-DBD-MySQL-4.044-1.el7.x86_64.rpm #此处报冲突,因为 perl-DBD-MySQL-4.023-6.el7.x86_64与perl-DBD-MySQL-4.044-1.el7.x86_64.rpm冲突了。
Preparing...                          ################################# [100%]
        file /usr/lib64/perl5/vendor_perl/Bundle/DBD/mysql.pm from install of perl-DBD-MySQL-4.044-1.el7.x86_64 conflicts with file from package perl-DBD-MySQL-4.023-6.el7.x86_64
        file /usr/lib64/perl5/vendor_perl/DBD/mysql.pm from install of perl-DBD-MySQL-4.044-1.el7.x86_64 conflicts with file from package perl-DBD-MySQL-4.023-6.el7.x86_64
        file /usr/lib64/perl5/vendor_perl/DBD/mysql/GetInfo.pm from install of perl-DBD-MySQL-4.044-1.el7.x86_64 conflicts with file from package perl-DBD-MySQL-4.023-6.el7.x86_64
        file /usr/lib64/perl5/vendor_perl/DBD/mysql/INSTALL.pod from install of perl-DBD-MySQL-4.044-1.el7.x86_64 conflicts with file from package perl-DBD-MySQL-4.023-6.el7.x86_64
        file /usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so from install of perl-DBD-MySQL-4.044-1.el7.x86_64 conflicts with file from package perl-DBD-MySQL-4.023-6.el7.x86_64
        file /usr/share/man/man3/Bundle::DBD::mysql.3pm.gz from install of perl-DBD-MySQL-4.044-1.el7.x86_64 conflicts with file from package perl-DBD-MySQL-4.023-6.el7.x86_64
        file /usr/share/man/man3/DBD::mysql.3pm.gz from install of perl-DBD-MySQL-4.044-1.el7.x86_64 conflicts with file from package perl-DBD-MySQL-4.023-6.el7.x86_64
        file /usr/share/man/man3/DBD::mysql::INSTALL.3pm.gz from install of perl-DBD-MySQL-4.044-1.el7.x86_64 conflicts with file from package perl-DBD-MySQL-4.023-6.el7.x86_64
[root@KerryDB tmp]# rpm -Uvh perl-DBD-MySQL-4.044-1.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:perl-DBD-MySQL-4.044-1.el7       ################################# [ 50%]
Cleaning up / removing...
   2:perl-DBD-MySQL-4.023-6.el7       ################################# [100%]
[root@KerryDB tmp]# 

当然,我们也可以下载源码安装,下载地址如下,但是最好使用cpan安装(cpan -f DBD::mysql),如果手工安装的话,各种依赖项缺少,会让你抓狂! 下面是我的一个源码安装的折腾过程。

https://cpan.metacpan.org/authors/id/D/DV/DVEEDEN/

从如下链接下载了DBD-mysql-4.050.tar.gz

https://cpan.metacpan.org/authors/id/D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz

# tar -xzvf DBD-mysql-4.050.tar.gz 
# cd DBD-mysql-4.050
# perl Makefile.PL
Can't locate Devel/CheckLib.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 12.
BEGIN failed--compilation aborted at Makefile.PL line 12.

如上所示,遇到这个错误,是因为没有安装perl-Devel-CheckLib包,缺少相关依赖组件。在安装包的文件META.json中,你就可以看到安装这个需要安装哪些组件。如下截图所示:

[root@KerryDB DBD-mysql-4.050]# yum list | grep "perl-Devel-CheckLib"
perl-Devel-CheckLib.noarch               0.99-2.el7                    base     
[root@KerryDB DBD-mysql-4.050]# yum list installed | grep "perl-Devel-CheckLib"
[root@KerryDB DBD-mysql-4.050]# yum install perl-Devel-CheckLib

接下来又遇到了“Can't exec "mysql_config": No such file or directory at Makefile.PL line 89”这个错误

[root@KerryDB DBD-mysql-4.050]# perl Makefile.PL
Can't exec "mysql_config": No such file or directory at Makefile.PL line 89.
 
Cannot find the file 'mysql_config'! Your execution PATH doesn't seem
not contain the path to mysql_config. Resorting to guessed values!
 
 
PLEASE NOTE:
 
For 'make test' to run properly, you must ensure that the
database user 'root' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
 
mysql> grant all privileges on test.* to 'root'@'localhost' identified by 's3kr1t';
 
You can also optionally set the user to run 'make test' with:
 
perl Makefile.PL --testuser=username
 
Can't exec "mysql_config": No such file or directory at Makefile.PL line 603.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Failed to determine directory of mysql.h. Use
 
  perl Makefile.PL --cflags=-I<dir>
 
to set this directory. For details see DBD::mysql::INSTALL,
section "C Compiler flags" or type
 
  perl Makefile.PL --help
 
 
[root@KerryDB mysql]#  which mysql_config
/usr/bin/which: no mysql_config in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
 
[root@KerryDB DBD-mysql-4.050]# locate mysql_config
/usr/bin/mysql_config_editor
/usr/share/man/man1/mysql_config_editor.1.gz

查一下相关资料,解决这个问题要么安装libmysqlclient-dev,要么在系统中查找mysql_config文件,在源码安装过程中加上参数选项(如下所示),具体情况根据你的环境而定,有可能你在源码安装过程还会遇到比我更多的错误。

# perl Makefile.PL --mysql_config=/usr/bin/mysql_config_editor
#make
#make test
#make install

更多安装相关资料,可以参考文档https://metacpan.org/pod/DBD::mysql::INSTALL

参考资料:

https://lefred.be/content/perl-mysql-8-0/

https://www.percona.com/doc/percona-monitoring-and-management/2.x/manage/conf-mysql-ps8.html

Percona Toolkit工具连接MySQL 8报错的解决方案的更多相关文章

  1. 连接mysql数据库报错java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized...解决方法

    今天连接mysql数据库报错如下: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or r ...

  2. 关于springboot 连接mysql 数据库报错问题

    springboot连接MySQL运行报错: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more ...

  3. idea启动服务连接mysql后 Navicat连接mysql就报错2013-Lost connection toMySQL server at

    我是使用navicat的windows端 连接centos下mysql服务器 第一次常规连接mysql正常,idea启动服务连接mysql后 Navicat连接mysql就报错2013-Lost co ...

  4. 解决Navicat连接MySQL总是报错1251的方法

    今天下了个 MySQL8.0,发现Navicat连接不上,总是报错1251: 原因是MySQL8.0版本的加密方式和MySQL5.0的不一样,连接会报错. 试了很多种方法,终于找到一种可以实现的: 更 ...

  5. JDBC driver连接MySQL运行报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than

    出错原因: 因为安装mysql的时候时区设置的不正确. mysql默认的是美国的时区,而我们中国大陆要比他们迟8小时,采用GMT+8:00格式. 也就是说是数据库和系统时区差异所造成的. 验证:运行c ...

  6. [大数据技术]Kettle初次连接MySQL数据库 报错问题 错误连接数据库 Error occured while trying to connect to the database Exception while loading class org.gjt.mm.mysql.Driver

    报错内容如下: 错误连接数据库 [foodmartconn] : org.pentaho.di.core.exception.KettleDatabaseException: Error occure ...

  7. 连接mysql客户端报错: java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'

    报这个错可能是因为用了低版本的的客户端.驱动连接高版本的mysql服务器. 解决方式有三种:升级客户端版本.修改服务端认证方式和适应服务端认证方式. 我是通过升级客户端版本解决,参考一下链接: Upg ...

  8. Node.js连接MySQL数据库报错

    解决Node.js第一次连接MySQL数据库时出现[SELECT ERROR] - ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authen ...

  9. jmeter连接mysql数据库报错Cannot create PoolableConnectionFactory (Could not create connection to database server.)

    今天在学习jmeter的jdbc取样器,发现在配置完JDBC Connection Configuration和JDBC Request后,点击运行.在查看结果树中显示响应数据: Cannot cre ...

随机推荐

  1. 立下flag!

    从今日(2020年6月29日)开始,直到两个月的暑假结束2020年8月31日,每天vp一场div3,至少要ac4道题目.

  2. Java JVM参数在idea里面配置

    找到你需要配置的启动类选择 接着点击Edit Configurations 在VM options里面配置就完成了

  3. xxe-xml外部实体注入

    XML文件格式及作用 copy至:https://www.runoob.com/xml/xml-tutorial.html 学习xxe为什么要了解XML和DTD,直接跳至Xxe查看: 定义&作 ...

  4. UCanCode发布升级E-Form++可视化源码组件库2020全新版 !

    2020年. 中国.成都 UCanCode发布升级E-Form++可视化源码组件库2020全新版 ! --- 全面性能提升,UCanCode有史以来最强大的版本发布! E-Form++可视化源码组件库 ...

  5. springboot实现防重复提交和防重复点击

    背景 同一条数据被用户点击了多次,导致数据冗余,需要防止弱网络等环境下的重复点击 目标 通过在指定的接口处添加注解,实现根据指定的接口参数来防重复点击 说明 这里的重复点击是指在指定的时间段内多次点击 ...

  6. [VBA原创源代码] excelhome 对花名册进行分类

    最近在学习<菜鸟谈VBA最最基础入门<原创>>,其中第22节有一个VBA编程作业,实现对花名册进行分类. 自己花了点时间,自己丫丫学步,终于实现出来. 在原创聚集地cnblog ...

  7. 关于继承、封装、多态、抽象和接口(Java)

    1.继承:    通过扩展一个已有的类,并继承该类的属性和行为,来创建一个新的类.已有的称为父类,新的类称为子类(父类派生子类,子类继承父类). (1)继承的优点:①代码的可重用性: ②父类的属性的方 ...

  8. Matlab中的uigetfile用法

    参考:https://ww2.mathworks.cn/help/matlab/ref/uigetfile.html?searchHighlight=uigetfile&s_tid=doc_s ...

  9. JavaFX ImageView

    例子1:显示4个狗头.正常显示左上角.右下角的狗头:右上角的狗头旋转180°,并设置了透明度:左下角的狗头旋转90°,也设置了透明度. 1 import javafx.application.Appl ...

  10. 2. 在TCGA中找到并下载意向数据

    听说过别人用生信分析"空手套白狼"的故事吧想做吗好想学哦~ 或多或少都知道GEO和TCGA这些公共数据库吧!那么你知道怎么在数据库上找到意向数据,并且成功下载呢?这第一步要难倒一大 ...