Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Connecting to mysql database

by Anonymous Monk
on Apr 29, 2010 at 11:00 UTC ( #837514=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://837514]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-09-28 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (124 votes). Check out past polls.

    Notices?