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.
4 Responses to Can’t locate DBI.pm in @INC Perl Script Error