http://qs1969.pair.com?node_id=837514

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

use DBI; print "Content-type:text/html\n\n"; $dbh = DBI->connect("dbi:mysql:database=; host=; user=; password=") or die "Connecting to MySQL database failed: $DBI::errstr"; #Removed database,host,user and password details obviously $sSQL = "SELECT FirstName, LastName FROM Users"; $st = $dbh->prepare($sSQL) or die "Preparing MySQL query failed: $DBI::errstr "; $st->execute() or die "The execution of the MySQL query failed: $DBI::errstr"; while ($row = $st->fetchrow_hashref()) { print " $row->{FirstName} $row->{LastName}"; } $dbh ->disconnect();

I am getting the below error when I am running this piece of code

install_driver(mysql) failed: Can't locate loadable object for module DBD::mysql in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at (eval 5) line 3 Compilation failed in require at (eval 5) line 3. Perhaps a module that DBD::mysql requires hasn't been fully installed at connect.pl line 5

I have already installed the DBD::mysql module through CPAN. cpan> install DBD::mysql DBD::mysql is up to date (4.014).

I am running it on Windows and perl version is v5.10.1.

Replies are listed 'Best First'.
Re: Connecting to mysql database
by Anonymous Monk on Apr 29, 2010 at 12:00 UTC
    I have already installed the DBD::mysql module through CPAN...

    Apparently it didn't go well, where is mysql.dll? I would re-install the module manually.

      Yes ,Of course !, you need to re-install ,watch the installation log, during this installation check the logs
      Best Regards, S.Sabarinathan,
Re: Connecting to mysql database
by Anonymous Monk on Apr 29, 2010 at 12:04 UTC
Re: Connecting to mysql database
by tweetiepooh (Hermit) on Apr 29, 2010 at 16:04 UTC
    One issue that I sometimes get is using the wrong Perl. I have different versions of Perl in different places (some on NFS shares so lots of machines can see the same Perl). If I install a module in one Perl (say /usr/local/bin/perl) but script (or path) uses another Perl (/usr/bin) then it may not have the modules. I have to take care to use the right version of the cpan (cpanp) tool for the Perl I want to use.

    I don't know if this is the same in Windows.