我dbd:mysql
通过安装cpan
。我有以下简单的脚本:
#!/usr/bin/perl -U
use DBI;
$ds = 'DBI:mysql:project:localhost'; $user = 'root'; $password = '123456';
$db = DBI->connect($ds, $user, $password) or die("Connection error\n");
$res = $db->prepare("SELECT * FROM root");
$res->execute();
while (my @row = $res->fetchrow_array()) { print $row[0]; }
$res->finish();
$db->disconnect();
当我从终端运行它时,一切都很好。但是,当我在浏览器中引用它时,会发生错误。Apache错误日志:
[错误] [客户端127.0.0.1] install_driver(mysql)失败:无法为模块DBD加载'/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle': mysql:dlopen(/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle,1):库未加载:libmysqlclient.18.dylib
[错误] [客户端127.0.0.1]引用自:/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
[错误] [客户端127.0.0.1]原因:在/System/Library/Perl/5.12/darwin-thread-multi-2level/DynaLoader.pm第204行找不到图像。
我安装mod_perl
并按照说明更改了httpd.conf
:
LoadModule perl_module libexec / apache2 / mod_perl.so
PerlModule Apache :: DBI
但是现在还没有开始阿帕奇。错误日志:
[错误]无法为模块DBD :: mysql:dlopen(/Library/Perl/5.12/darwin)加载'/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle' -thread-multi-2level / auto / DBD / mysql / mysql.bundle,1):库未加载:libmysqlclient.18.dylib \ n引用自:/Library/Perl/5.12/darwin-thread-multi-2level/auto /DBD/mysql/mysql.bundle\n原因:在/System/Library/Perl/5.12/darwin-thread-multi-2level/DynaLoader.pm第204行找不到图像。\ n在(评估6)第2行\ n编译在(eval 6)第2行上的require失败。\ n
[错误]无法为服务器MacBook-Pro-Evgenij.local:0加载Perl模块DBD :: Mysql,正在退出...
如何解决这个问题呢?