我在Windows 7 64位计算机上使用ppm 4.19的perl 5.18.1.1800。
我需要使用才能从perl访问mysql。但我得到的错误信息如下:
use DBI();
my $dbh = DBI->connect("DBI:mysql:database=mydbname;host=localhost","myuser", "mypass",{'RaiseError' => 1})install_driver(mysql)失败:无法在@INC中找到DBD/mysql.pm (您可能需要安装DBD::mysql模块)
所以我试着安装DBD,但是在我的PPM中没有列出这一点。在命令行中,当我试图安装时,会出现以下错误
ppm install DBD-mysqlppm安装失败:找不到任何提供DBD-mysql的包
我试着下载并安装它,但是它需要一个我没有的C编译器。
在DBD-mysql信息页中,没有提到Perl5.18对模块的支持。
那么,我应该回到5.16.xx或者问题是别的什么吗?
谢谢,
发布于 2014-10-04 15:05:21
DBD可用于ActivePerl-5.16.3.1604.返回到那个版本可能比安装编译器来自己构建包更简单。
Activestate使用Visual构建DBD:http://ppm4.activestate.com/MSWin32-x86/5.16/1600/C/CA/CAPTTOFU/DBD-mysql-4.022.d/log-20120830T032945.txt

C:\>ppm install DBD-mysql
Downloading ActiveState Package Repository packlist...done
Updating ActiveState Package Repository database...done
Syncing site PPM database with .packlists...done
Downloading DBD-mysql-4.022...done
Unpacking DBD-mysql-4.022...done
Generating HTML for DBD-mysql-4.022...done
Updating files in site area...done
12 files installed发布于 2014-10-04 14:49:10
模块的名称是DBI。试着使用:
ppm install DBI*免责声明:我没有在Windows上使用Perl,而是在Linux上使用Perl,所以我假设使用ppm的语法是"ppm安装模块名“。
此外,下面正确的语法是:
my $dbh = DBI->connect(DBI:mysql:DBNAME, $username, $pass, {RaiseError => 1, AutoCommit
=> 1}) or die "Could not Connect to DB"; https://stackoverflow.com/questions/26190551
复制相似问题