Linux

Dockerized Sysbench 無法連接到 Mysql

  • October 31, 2019

我正在嘗試遵循教程。

它沒有給出Mysql版本要求。因此,我嘗試使用 Mysql 8.0.18 Community Server 來使用這些命令進行連接。

我已經在 Mysql 8 中創建了所需的內容:

mysql> CREATE SCHEMA sbtest;
mysql> CREATE USER sbtest@'%' IDENTIFIED BY 'MyPassword+1';
mysql> GRANT ALL PRIVILEGES ON sbtest.* to sbtest@'%';

比使用第一個命令創建的腳本文件:

[root@host ~]# cat sbpreparing
docker run \
--rm=true \
--name=sb-prepare \
severalnines/sysbench \
sysbench \
--db-driver=mysql \
--oltp-table-size=100000 \
--oltp-tables-count=24 \
--threads=1 \
--mysql-host=192.168.1.200 \
--mysql-port=3306 \
--mysql-user=sbtest \
--mysql-password=MyPassword+1 \
/usr/share/sysbench/tests/include/oltp_legacy/parallel_prepare.lua \
run

並啟動它:

[root@host ~]# ./sbpreparing
sysbench 1.0.17 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Initializing worker threads...

Threads started!

thread prepare0
Creating table 'sbtest1'...
FATAL: unable to connect to MySQL server on host '192.168.1.200', port 3306, aborting...
FATAL: error 2059: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/x86_64-linux-gnu/mariadb18/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
FATAL: `thread_run' function failed: /usr/share/sysbench/tests/include/oltp_legacy/common.lua:66: Failed to connect to the database
Error in my_thread_global_end(): 1 threads didn't exit

我可以使用命令從同一台機器連接到 MySQL 伺服器:

mysql -h 192.168.1.200 -u sbtest -pMyPassword+1

但 sysbench 做不到。我該如何解決?謝謝!

在 mustaccio 的幫助下,我按照這個答案中的說明解決了這個問題:

  1. 在 中的下一個字元串之前刪除了一個註釋符號/etc/my.cnf

default_authentication_plugin=mysql_native_password 2. 以root身份連接:

mysql -u root -pMyPassword+1 3. 執行下一個查詢:

ALTER USER 'sbtest'@'%' IDENTIFIED WITH mysql_native_password BY 'MyPassword+1';

按照這些說明 Sysbench 成功連接到 Mysql 8 並成功執行所有準備任務。

引用自:https://dba.stackexchange.com/questions/252313