3 Replies Latest reply: Jan 23, 2014 5:27 PM by Melophage
ocram88 Level 1 (0 points)


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





use strict;

use DBI;


my $dbh = DBI->connect(         




    { RaiseError => 1 },        

) or die $DBI::errstr;


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



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


print @$ver;

print "\n";







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)