sysbench 压测无法连接MySQL 8.0

报错:

FATAL: unable to connect to MySQL server on host '127.0.0.1', port 3377, aborting...
FATAL: error 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
FATAL: `sysbench.cmdline.call_command' function failed: /usr/share/sysbench/oltp_common.lua:83: connection creation faile

sysbench 测试OLTP报上面错误,FATAL: error 2059: Authentication plugin 'caching_sha2_password' cannot be loaded:
认证组件“caching_sha2_password”没有被加载,在mysql 8.0 以后,用户连接默认认证组件改为“caching_sha2_password”,
mysql 5.7以前,默认的用户认证组件为“mysql_native_password”。

MySQL 8.0 调整密码验证规则(改为可以设置简单密码):

set global validate_password.policy=0;
set global validate_password.length=1;

create database sbtest;
CREATE USER 'yoon'@'%' IDENTIFIED BY 'hankyoon';
GRANT ALL ON *.* TO 'tony'@'%';
flush privileges;

若提示上面参数不存在,用如下方式:

 

mysql> select user,host,plugin,authentication_string from mysql.user where user = 'root' \G
*************************** 1. row ***************************
                 user: root
                 host: localhost
               plugin: caching_sha2_password
authentication_string: $A$005$@sQuHfw   _n.O=uMu7uxyHg/fN/F4oFggtYfIOERF11GGQEjcAL0xFJHoCA
1 row in set (0.00 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY 'xxxxxxxxxx';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> select user,host,plugin,authentication_string from mysql.user where user = 'root' \G
*************************** 1. row ***************************
                 user: root
                 host: localhost
               plugin: mysql_native_password
authentication_string: *AD04915810305F8091B9C67A0CCE68566BB80611

 

修改:

ALTER USER yoon IDENTIFIED WITH mysql_native_password;  #这一步会把密码清空

alter user 'yoon'@'%' identified with mysql_native_password by 'hankyoon';

压测:

sysbench oltp_read_write --mysql-host=xxx.xxx.xxx.xxx --mysql-port=3377 --mysql-user=yoon --mysql-password='hankyoon' --mysql-db=sbtest --tables=30 --table-size=1000000 --threads=30 prepare

sysbench oltp_read_write --mysql-host=xxx.xxx.xxx.xxx --mysql-port=3377 --mysql-user=yoon --mysql-password='hankyoon' --mysql-db=sbtest --tables=30 --table-size=1000000 --threads=10 --time=60 --report-interval=10 run

 

posted @ 2023-02-13 11:32  __Yoon  阅读(287)  评论(0编辑  收藏  举报