1

I installed dbd:mysql via cpan. I have the following simple script:

#!/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();

When I run it from terminal then everything is fine. But when I refer to it in the browser an error occurs. Apache error log:

[error] [client 127.0.0.1] install_driver(mysql) failed: Can't load '/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib

[error] [client 127.0.0.1] Referenced from: /Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle

[error] [client 127.0.0.1] Reason: image not found at /System/Library/Perl/5.12/darwin-thread-multi-2level/DynaLoader.pm line 204.

I installed mod_perl and following the instructions changed the httpd.conf:

LoadModule perl_module libexec/apache2/mod_perl.so

PerlModule Apache::DBI

But now does not start apache. Error log:

[error] Can't load '/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib\n Referenced from: /Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle\n Reason: image not found at /System/Library/Perl/5.12/darwin-thread-multi-2level/DynaLoader.pm line 204.\n at (eval 6) line 2\nCompilation failed in require at (eval 6) line 2.\n

[error] Can't load Perl module DBD::Mysql for server MacBook-Pro-Evgenij.local:0, exiting...

How to solve this problem?

1

I created a symlink in /usr/lib/ to /usr/local/mysql-5.5.23-osx10.6-x86_64/lib/libmysqlclient.18.dylib, rebuilt dbd:mysql and everything was working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.