# Solved: Problem installing the perl cpan DBD::MySQL module



## andynic (May 25, 2007)

I am trying to install DBD for mysql, Perl 5.10, Mac OS X 10.6 and receive the errors shown at the end of this post.

I have done the following:
From http://search.cpan.org/~capttofu/DBD-mysql/
downloaded DBD-mysql-4.018 to /Users/gnicastro/Downloads

cd /Users/gnicastro/Downloads/DBD-mysql-4.018
perl Makefile.PL --testdb=test --testuser=root --testpassword=pw_for_mysql_root
perl -pi -e's/MACOSX/env MACOSX/' Makefile
make test

=============================
The instructions said the above "make test" command is optional. It returns a slew of errors, among them, for example,
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base....................ok 
t/10connect.................skipped
all skipped: ERROR: Access denied for user 'user'@'localhost' (using password: YES) Can't continue test
t/20createdrop..............skipped
all skipped: ERROR: Access denied for user 'user'@'localhost' (using password: YES). Can't continue test
t/25lockunlock..............skipped
etc.

But please note that the following does work:
mysql --user=root --password=mysql_root_pw test
=============================

Since the "make test" command is opitonal, I then continued with:
sudo make install

=============================
That last command produced the following results:
/Users/gnicastro/Downloads/DBD-mysql-4.018
gnicastro$ sudo make install
Password:
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Installing /Library/Perl/5.10.0/darwin-thread-multi-2level/Bundle/DBD/mysql.pm
Installing /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm
Installing /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql/GetInfo.pm
Installing /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql/INSTALL.pod
Appending installation info to /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level/perllocal.pod
gnicastro$ 
=============================

=============================
I then tried the following perl script:
# Test DBI and DBD
# Install DBI and DBD instructions: http://bixsolutions.net/forum/thread-8.html

use strict;
use warnings;

use DBI;
use DBD::MySQL;

my $GCdbSchemaName = "gfrm";
my $GCdbUn = "gfrm";
my $GCdbPw = "gfrm";

my $dbHandle = DBI->connect("DBI:mysql:database=$GCdbSchemaName", $GCdbUn, $GCdbPw);
my $cmdHandle = $dbHandle->prepare("SELECT * FROM user");
$cmdHandle->execute();

while (my $ref = $cmdHandle->fetchrow_arrayref) {
print $ref->[1] . "\n";
}

exit;
=============================

=============================
The above perl script causes the following errors:
gnicastro$ perl -w testDBIandDBD.pl
Subroutine driver redefined at /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm line 21.
Subroutine CLONE redefined at /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm line 38.
Subroutine _OdbcParse redefined at /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm line 42.
Subroutine _OdbcParseHost redefined at /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm line 77.
...
=============================

Any ideas of what I might have done wrong? How I can fix it?

Thanks for your help,
Andy Nicastro
Mac OS X 10.6
Perl 5.10


----------



## andynic (May 25, 2007)

Solution:

The problem is the line in the test script: 
use DBD::MySQL;
The line above it (use DBI is sufficient.
Andynic


----------

