Windows下Strawberry Perl安装DBD::mysql失败及测试异常求助
解决DBD::mysql在Strawberry Perl 5.38.2上的安装测试失败问题
环境信息
- Windows 11
- Strawberry Perl 5.38.2
- MySQL 8.0.37
问题描述
安装DBD::mysql后执行make test时,多数测试返回Dubious(无子测试运行),最后一个测试t/30insertfetch.t无响应。Strawberry Perl发布说明提示TODO: libmysql needs updates before DBD::mysql can be built.,但不知道具体操作方法。
操作过程输出
cpan> look for DBD::mysql Database was generated on Wed, 26 Jun 2024 17:37:09 GMT Warning: Cannot look for, don't know what it is. Try the command i /for/ to find objects with matching identifiers. Running look for module 'DBD::mysql' Trying to open a subshell in the build directory... Checksum for D:\apps\strawberry\cpan\sources\authors\id\D\DV\DVEEDEN\DBD-mysql-5.006.tar.gz ok Scanning cache D:\apps\strawberry\cpan\build for sizes ............................................................................DONE Working directory is D:\apps\strawberry\cpan\build\DBD-mysql-5.006-2 Microsoft Windows [Version 10.0.22631.3737] (c) Microsoft Corporation. All rights reserved. D:\apps\strawberry\cpan\build\DBD-mysql-5.006-2>perl MakeFile.PL PLEASE NOTE: For 'make test' to run properly, you must ensure that the database user '' 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> CREATE USER ''@'localhost' IDENTIFIED BY 's3kr1t'; mysql> GRANT ALL PRIVILEGES ON test.* TO ''@'localhost'; You can also optionally set the user to run 'make test' with: perl Makefile.PL --testuser=username I will use the following settings for compiling and testing: cflags (mysql_config) = -ID:/apps/MySQL/MySQLServer/include ldflags (mysql_config) = libs (mysql_config) = -LD:/apps/MySQL/MySQLServer/lib -lmysql mysql_config (guessed ) = mysql_config nocatchstderr (default ) = 0 nofoundrows (default ) = 0 testdb (default ) = test testhost (default ) = testpassword (default ) = testport (default ) = testsocket (default ) = testuser (guessed ) = version (mysql_config) = 8.0.37 To change these settings, see 'perl Makefile.PL --help' and 'perldoc DBD::mysql::INSTALL'. Checking if libs are available for compiling... Looks good. Checking if your kit is complete... Looks good Using DBI 1.643 (for perl 5.038002 on MSWin32-x64-multi-thread) installed in D:/apps/strawberry/perl/vendor/lib/auto/DBI/ Generating a gmake-style Makefile Writing Makefile for DBD::mysql "\x{0159}" does not map to cp437 at D:/apps/strawberry/perl/lib/ExtUtils/MakeMaker.pm line 1271. "\x{0159}" does not map to cp437 at D:/apps/strawberry/perl/lib/ExtUtils/MakeMaker.pm line 1271. "\x{0159}" does not map to cp437 at D:/apps/strawberry/perl/lib/ExtUtils/MakeMaker.pm line 1271. Writing MYMETA.yml and MYMETA.json D:\apps\strawberry\cpan\build\DBD-mysql-5.006-2>make test "D:\apps\strawberry\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- mysql.bs blib\arch\auto\DBD\mysql\mysql.bs 644 "D:\apps\strawberry\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t t/00base.t .............................. 1/6 # Driver version is 5.006 t/00base.t .............................. ok t/01caching_sha2_prime.t ................ Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/05dbcreate.t .......................... Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/10connect.t ........................... Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/15reconnect.t ......................... Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/16dbi-get_info.t ...................... Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/17quote.t ............................. Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/20createdrop.t ........................ Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/25lockunlock.t ........................ Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/29warnings.t .......................... Dubious, test returned 116 (wstat 29696, 0x7400) No subtests run t/30insertfetch.t .......................
解决方法
1. 替换兼容的libmysql.dll
Strawberry Perl自带的libmysql版本与MySQL 8.0.37不兼容,需手动替换:
- 下载MySQL 8.0.37对应x64架构的
libmysql.dll - 替换Strawberry Perl目录下
perl\bin中的同名文件
2. 配置测试用户权限
测试使用空用户名导致连接失败,需创建专用测试用户:
- 登录MySQL执行:
CREATE USER 'dbtest'@'localhost' IDENTIFIED BY 'testpass'; GRANT ALL PRIVILEGES ON test.* TO 'dbtest'@'localhost'; FLUSH PRIVILEGES; - 重新生成Makefile并指定测试用户:
perl Makefile.PL --testuser=dbtest --testpassword=testpass
3. 修复字符编码错误
命令行编码不兼容导致报错,先切换编码再执行操作:
chcp 65001 perl Makefile.PL make test
4. 跳过测试直接安装(临时方案)
若测试仍无法通过,可跳过测试直接安装:
make install
注意:此方法跳过兼容性验证,运行时可能出现未知问题。
内容的提问来源于stack exchange,提问作者dtryingtocode
相关产品推荐
相关产品推荐

