gpt4 book ai didi

mysql - 带有 MySQL 的 Perl 模块 DBI 抛出 "error 2026 recorded: SSL connection error: protocol version mismatch"

转载 作者:行者123 更新时间:2023-11-30 22:08:27 34 4
gpt4 key购买 nike

在你提示之前有人问过这个问题:我不想建立 ssl 连接。

我只是尝试从我的客户端(Ubuntu 16.04)连接:

mysql Ver 15.1 Distrib 10.0.27-MariaDB

到较旧的 MySQL 服务器(在 solaris 上运行):

5.5.10-log MySQL Community Server (GPL)

用 perl。

我试图显式禁用 mysql_ssl 但它似乎没有任何改变。

当我使用如下所示的相同 perl 代码连接到另一个具有实际版本的 MariaDB 时,没有错误。当我在命令行上使用 MySQL-Client 连接到旧的 MySQL-Server 时,没有错误。

服务器变量设置如下:

MySQL [(none)]> show variables like '%ssl%';
+---------------+--------------------------------+
| Variable_name | Value |
+---------------+--------------------------------+
| have_openssl | YES |
| have_ssl | YES |
| ssl_ca | /etc/mysql/ssl/ca-cert.pem |
| ssl_capath | |
| ssl_cert | /etc/mysql/ssl/server-cert.pem |
| ssl_cipher | |
| ssl_key | /etc/mysql/ssl/server-key.pem |
+---------------+--------------------------------+

我的 perl 代码如下所示:

$ perl -e '
use DBI;
DBI->trace("15|CON");
my $dbh = DBI->connect("DBI:mysql:host=my_dbhost;database=test;", "test", "test",
{
PrintError => 1,
RaiseError => 1,
mysql_ssl => 0,
mysql_skip_secure_auth => 1
});
$dbh->disconnect();'

这是调试级别 15 的输出:

    DBI 1.634-ithread default trace level set to 0x200/15 (pid 11328 pi ee1010) at -e line 1
-> DBI->connect(DBI:mysql:host=my_dbhost;database=test;, test, ****, HASH(0xee3f30))
-> DBI->install_driver(mysql) for linux perl=5.022001 pid=11328 ruid=10000 euid=10000
install_driver: DBD::mysql version 4.033 loaded from /usr/lib/x86_64-linux-gnu/perl5/5.22/DBD/mysql.pm
New 'DBI::dr' (for DBD::mysql::dr, parent='', id=undef)
dbih_setup_handle(DBI::dr=HASH(0x11e6848)=>DBI::dr=HASH(0xf184e8), DBD::mysql::dr, 0, Null!)
dbih_make_com(Null!, 0, DBD::mysql::dr, 152, 0) thr#ee1010
dbih_setup_attrib(DBI::dr=HASH(0xf184e8), Err, Null!) SCALAR(0x1016f28) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0xf184e8), State, Null!) SCALAR(0x10db678) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0xf184e8), Errstr, Null!) SCALAR(0x103c648) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0xf184e8), TraceLevel, Null!) 0 (already defined)
dbih_setup_attrib(DBI::dr=HASH(0xf184e8), FetchHashKeyName, Null!) 'NAME' (already defined)
install_method DBI::db::mysql_fd
install_method DBI::db::mysql_async_result
install_method DBI::db::mysql_async_ready
install_method DBI::st::mysql_async_result
install_method DBI::st::mysql_async_ready
<- install_driver= DBI::dr=HASH(0x11e6848)
>> connect DISPATCH (DBI::dr=HASH(0x11e6848) rc2/3 @5 g2 ima8001 pid#11328) at /usr/lib/x86_64-linux-gnu/perl5/5.22/DBI.pm line 683
!! The warn '0' was CLEARED by call to connect method
-> connect for DBD::mysql::dr (DBI::dr=HASH(0x11e6848)~0xf184e8 'host=my_dbhost;database=test;' 'test' **** HASH(0x106d978)) thr#ee1010
New 'DBI::db' (for DBD::mysql::db, parent=DBI::dr=HASH(0xf184e8), id=HASH(0x12164b8))
dbih_setup_handle(DBI::db=HASH(0x1216338)=>DBI::db=HASH(0x121ce50), DBD::mysql::db, 10db930, HASH(0x12164b8))
dbih_make_com(DBI::dr=HASH(0xf184e8), f0fd90, DBD::mysql::db, 192, 121cd78) thr#ee1010
dbih_setup_attrib(DBI::db=HASH(0x121ce50), Err, DBI::dr=HASH(0xf184e8)) SCALAR(0x10f2d70) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x121ce50), State, DBI::dr=HASH(0xf184e8)) SCALAR(0x10f2dd0) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x121ce50), Errstr, DBI::dr=HASH(0xf184e8)) SCALAR(0x10f2da0) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x121ce50), TraceLevel, DBI::dr=HASH(0xf184e8)) 0 (already defined)
dbih_setup_attrib(DBI::db=HASH(0x121ce50), FetchHashKeyName, DBI::dr=HASH(0xf184e8)) 'NAME' (already defined)
dbih_setup_attrib(DBI::db=HASH(0x121ce50), HandleSetErr, DBI::dr=HASH(0xf184e8)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x121ce50), HandleError, DBI::dr=HASH(0xf184e8)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x121ce50), ReadOnly, DBI::dr=HASH(0xf184e8)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x121ce50), Profile, DBI::dr=HASH(0xf184e8)) undef (not defined)
imp_dbh->connect: dsn = host=my_dbhost;database=test;, uid = test, pwd = test
imp_dbh->my_login : dbname = test, uid = test, pwd = test,host = my_dbhost, port = NULL
imp_dbh->mysql_dr_connect: host = |my_dbhost|, port = 0, uid = test, pwd = test
imp_dbh->mysql_dr_connect: Skipping secure auth
imp_dbh->bind_type_guessing: 0
imp_dbh->use_server_side_prepare: 0
imp_dbh->mysql_dr_connect: client_flags = 2
imp_dbh->mysql_dr_connect: <- --> do_error
SSL connection error: protocol version mismatch error 2026 recorded: SSL connection error: protocol version mismatch
<-- do_error
>> DESTROY DISPATCH (DBI::db=HASH(0x1216338) rc1/1 @1 g2 ima10004 pid#11328) at /usr/lib/x86_64-linux-gnu/perl5/5.22/DBD/mysql.pm line 163 via at -e line 1
<> DESTROY(DBI::db=HASH(0x1216338)) ignored for outer handle (inner DBI::db=HASH(0x121ce50) has ref cnt 2)
>> DESTROY DISPATCH (DBI::db=HASH(0x121ce50) rc1/1 @1 g2 ima10004 pid#11328) at /usr/lib/x86_64-linux-gnu/perl5/5.22/DBI.pm line 683 via at -e line 1
-> DESTROY for DBD::mysql::db (DBI::db=HASH(0x121ce50)~INNER) thr#ee1010
DESTROY for DBI::db=HASH(0x121ce50) ignored - handle not initialised
ERROR: 2026 'SSL connection error: protocol version mismatch' (err#0)
<- DESTROY= ( undef ) [1 items] at /usr/lib/x86_64-linux-gnu/perl5/5.22/DBI.pm line 683 via at -e line 1
DESTROY (dbih_clearcom) (dbh 0x121ce50, com 0x123c3b0, imp DBD::mysql::db):
FLAGS 0x100211: COMSET Warn PrintWarn AutoCommit
ERR 2026
ERRSTR 'SSL connection error: protocol version mismatch'
PARENT DBI::dr=HASH(0xf184e8)
KIDS 0 (0 Active)
IMP_DATA HASH(0x12164b8)
dbih_clearcom 0x121ce50 (com 0x123c3b0, type 2) done.

!! ERROR: 2026 'SSL connection error: protocol version mismatch' (err#0)
<- connect= ( undef ) [1 items] at /usr/lib/x86_64-linux-gnu/perl5/5.22/DBI.pm line 683
-> $DBI::errstr (&) FETCH from lasth=HASH
>> DBD::mysql::dr::errstr
<- $DBI::errstr= 'SSL connection error: protocol version mismatch'
DBI connect('host=my_dbhost;database=test;','test',...) failed: SSL connection error: protocol version mismatch
DBI connect('host=my_dbhost;database=test;','test',...) failed: SSL connection error: protocol version mismatch at -e line 1.
-- DBI::END ($@: , $!: )
>> disconnect_all DISPATCH (DBI::dr=HASH(0x11e6848) rc1/3 @1 g2 ima801 pid#11328) at /usr/lib/x86_64-linux-gnu/perl5/5.22/DBI.pm line 762 via at /usr/share/perl/5.22/Carp.pm line 166
!! The ERROR '2026' was CLEARED by call to disconnect_all method
-> disconnect_all for DBD::mysql::dr (DBI::dr=HASH(0x11e6848)~0xf184e8) thr#ee1010
<- disconnect_all= ( ) [0 items] (not implemented) at /usr/lib/x86_64-linux-gnu/perl5/5.22/DBI.pm line 762 via at /usr/share/perl/5.22/Carp.pm line 166
! >> DESTROY DISPATCH (DBI::dr=HASH(0xf184e8) rc1/1 @1 g2 ima10004 pid#11328) during global destruction
! -> DESTROY in DBD::_::common for DBD::mysql::dr (DBI::dr=HASH(0xf184e8)~INNER) thr#ee1010
! <- DESTROY= ( undef ) [1 items] during global destruction
DESTROY (dbih_clearcom) (drh 0x11e6848, com 0xf0fd90, imp global destruction):
FLAGS 0x100215: COMSET Active Warn PrintWarn AutoCommit
PARENT undef
KIDS 0 (0 Active)
dbih_clearcom 0x11e6848 (com 0xf0fd90, type 1) done.

! >> DESTROY DISPATCH (DBI::dr=HASH(0x11e6848) rc1/1 @1 g2 ima10004 pid#11328) during global destruction
! <> DESTROY for DBI::dr=HASH(0x11e6848) ignored (inner handle gone)

perl 使用的库:

$ ldd /usr/lib/x86_64-linux-gnu/perl5/5.22/auto/DBD/mysql/mysql.so | grep libmysqlclient
libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007f3fbef0f000)

$ dpkg -S libmysqlclient.so.20
libmysqlclient20:amd64: /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20
libmysqlclient20:amd64: /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20.3.3

$ dpkg -l libmysqlclient20
libmysqlclient20:amd64 5.7.16-0ubuntu0.16.0 amd64 MySQL database client library

关于如何在连接上真正禁用 ssl 有什么想法吗?提前致谢!

最佳答案

解决方法似乎是编译 DBD::mysql 而不是预编译 Ubuntu。我在示例中使用了 mariadb 库。我在最小安装的 Ubuntu 16.04 上所做的是:

$ sudo apt install libmariadb-client-lgpl-dev libdbi-perl gcc
$ sudo ln -s /usr/bin/mariadb_config /usr/bin/mysql_config
$ sudo perl -MCPAN -eshell
cpan[1]> install DBD::mysql

之后我从上面的 perl 调用工作正常。我将在 ubuntu 上提交错误。

关于mysql - 带有 MySQL 的 Perl 模块 DBI 抛出 "error 2026 recorded: SSL connection error: protocol version mismatch",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40914920/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com