Skip navigation

Can't locate DBD/mysql.pm in @INC

267 Views 3 Replies Latest reply: Jan 23, 2014 5:27 PM by Melophage RSS
ocram88 Calculating status...
Currently Being Moderated
Jan 23, 2014 12:06 AM

Hi!

I'm trying to use mySql database whit perl scripts. I wrote the following script:

 

----------------------------------

#!/usr/bin/perl

 

use strict;

use DBI;

 

my $dbh = DBI->connect(         

    "DBI:mysql:dbname=mydb",

    "user12",                         

    "34klq*",                         

    { RaiseError => 1 },        

) or die $DBI::errstr;

 

my $sth = $dbh->prepare("SELECT VERSION()");

$sth->execute();

 

my $ver = $sth->fetch();

 

print @$ver;

print "\n";

 

 

$sth->finish();

$dbh->disconnect();

----------------------------------

 

but in terminal I get:

 

mbp-di-marco:myperl marcomac$ perl my_script.pl

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/auto/DBD /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/BDB /opt/local/lib/perl5/site_perl/5.12.4/BDB /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/DBI/BDB /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.12.4 /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.12.4 /opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/5.12.4 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl .) at (eval 5) line 3.

Perhaps the DBD::mysql perl module hasn't been fully installed,

or perhaps the capitalisation of 'mysql' isn't right.

Available drivers: DBM, ExampleP, File, Gofer, Multiplex, Proxy, Sponge.

at available_drivers.pl line 7.

 

 

What can I do to make it work?

Thank you.

MacBook Pro (13-inch Mid 2012), OS X Mavericks (10.9.1)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.