Can’t locate DBI.pm in @INC Perl Script Error

Today after FreeBSD server upgrade with portupgrade and freebsd-update, i started getting following error on a CGI script that use MySQL database.


Can’t locate DBI.pm in @INC
(@INC contains: /usr/local/flashcp/
/usr/local/lib/perl5/5.8.8/BSDPAN
/usr/local/lib/perl5/site_perl/5.8.8/mach
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.8/mach
/usr/local/lib/perl5/5.8.8 .)
at /home/free/cgi-bin/index.cgi line 8.
BEGIN failed–compilation aborted

This error is due to Perl module DBI is missing, to install it, i loged in to server and run cpan, cpanel allow you to install Perl modules.


server22# cpan
cpan> install DBI
Running install for module DBI
Running make for T/TI/TIMB/DBI-1.50.tar.gz
LWP not available
Fetching with Net::FTP:
DBI-1.50.tar.gz
CPAN: Digest::MD5 loaded ok
LWP not available
Fetching with Net::FTP:

FreeBSD: Registering installation in the package database
Appending installation info to /usr/local/lib/perl5/5.8.8/mach/perllocal.pod
/usr/bin/make install — OK


cpan> exit
Terminal does not support GetHistory.
Lockfile removed.
server22#

after installation type “exit” to exit cpan shell. AFter installing DBI, i refreshed the CGI script, the error is gone, now i start getting different error

install_driver(mysql) failed:
Can’t locate DBD/mysql.pm in @INC
(@INC contains: /usr/local/flashcp/
/usr/local/lib/perl5/5.8.8/BSDPAN
/usr/local/lib/perl5/site_perl/5.8.8/mach
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.8/mach
/usr/local/lib/perl5/5.8.8 .) at (eval 8) 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, Proxy, Sponge.
at /home/free/cgi-bin/index.cgi line 16

To fix the problem, need to install DBD::mysql module, so back to cpan

install DBD::mysql did not worked, this is because it try to connect MySQL database for testing, but MySQL login with out password is disabled in the server. So we have to do force install

server22# cpan
Terminal does not support AddHistory.


cpan shell — CPAN exploration and modules installation (v1.7602)
ReadLine support available (try ‘install Bundle::CPAN’)


cpan> force install DBD::mysql

/usr/bin/make install — OK

cpan> exit
Terminal does not support GetHistory.
Lockfile removed.
server22#

After installing DBD::mysql the perl script start working.

Related posts:

  1. Cpanel Error – Can’t locate DBD/mysql.pm
  2. Cpanel Error – Can’t locate DBD/mysql.pm
  3. Cpanel Server Account Creation Error
  4. Cpanel Show Current Disk Usage not working
  5. CPAN configuration
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Can’t locate DBI.pm in @INC Perl Script Error

  1. Anonymous says:

    Thankyou so much for posting this! Was exactly what I was having trouble with and the fix was exactly the same

  2. Mike Wagan says:

    thanks! have been looking all around for this solution!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>