24

Install information:

Using DBI 1.608 (for perl 5.008009 on x86_64-linux) installed in /usr/local/lib/perl5/site_perl/5.8.9/x86_64-linux/auto/DBI/

error information:

[root@datacenterETL DBD-mysql-4.020]# perl ../testConnect.pl install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.9/x86_64-linux /usr/local/lib/perl5/5.8.9 /usr/local/lib/perl5/site_perl/5.8.9/x86_64-linux /usr/local/lib/perl5/site_perl/5.8.9 .) at (eval 3) line 3.

Perhaps the DBD::mysql Perl module hasn't been fully installed, or perhaps the capitalisation of 'mysql' isn't right.

6 Answers 6

64

It looks like you're using Linux. In that case, you might find it easier to install a pre-packaged version of the module.

On a Red Hat derivative try yum install perl-DBD-mysql; on a Debian derivative try apt-get install libdbd-mysql-perl.

6
  • 2
    A big thank you, yum worked for my CentOS 5.x box. Sep 26, 2014 at 15:47
  • 2
    worked also for me under ubuntu 16.04 where installing from cpan did not. Thanks!
    – zippy
    Jun 17, 2016 at 16:37
  • using debian didn't worked for me, after installation of module is there need of it to enable in apache config? or something else? restarted apache already Feb 21, 2019 at 17:52
  • @vishal-mote: No need to enable it or restart Apache. But just saying it "didn't work" doesn't give me any useful information to go on. What, exactly, did you see (or not see)? It's probably worth raising this as a separate question.
    – Dave Cross
    Feb 21, 2019 at 18:15
  • could you please look once into my problem on below link, it will be really helpful stackoverflow.com/questions/54813743/… Feb 21, 2019 at 18:24
13

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

...so install it.

cpan DBD::mysql

Or since you don't have internet access,

perl Makefile.PL
make
make test
make install

You'll need MySQL's development header files installed first, as per INSTALL

7
  • perl Makefile.PL --mysql_config=/usr/bin/mysql_config
    – Albert
    Jun 17, 2013 at 9:58
  • @user2492829, What is that?
    – ikegami
    Jun 17, 2013 at 10:00
  • 1
    So use the four command process described in the Synopsis of the file I linked.
    – ikegami
    Jun 17, 2013 at 10:03
  • 1
    No, that doesn't install anything. That just generates the Makefile you will use to install the module.
    – ikegami
    Jun 17, 2013 at 10:10
  • 1
    As I mentioned, the commands are listed in the Synopsis of the file I linked. I've even added them to my answer already.
    – ikegami
    Jun 17, 2013 at 10:18
5

any error related to DBD::mysql error has not installed fully. Please run the below code in super user permission.

apt-get install libdbd-mysql-perl
0
2

As is was not able to comment (yet), I want to add something for the Mac Users. I hat to add the --force command to install the everything properly as i have no local mySQL installation for the tests to pass. /usr/bin/cpanm --force DBD::mysql worked for me. (Mac OS 10.9.2, Perl 5.12.4)

1
  • It's ridiculous to blindly use --force!
    – ikegami
    Feb 27, 2017 at 5:51
0

I've been tried perl -MCPAN -e shell on my mac OSX 10.8.5, but this didn't work.

I tried sudo perl -MCPAN ..., but didn't work too. I changed my ~.bash_profile to include

LD_RUN_PATH=/usr/local/mysql-5.6.13-osx10.7-x86_64/lib export LD_RUN_PATH 
LD_LIBRARY_PATH=/usr/local/mysql-5.6.13-osx10.7-x86_64/lib export LD_LIBRARY_PATH 

lines, and I tried -MCPAN again, with and without sudo, but this didn't work too.

I read some posts and I tried "get Bundle::DBD::mysql" in -MCPAN command line to download it and install with Makefile. Then, I entered the ~./cpan/build directory and I did a Makefile, but the make command didn't work. I tried Makefile with --testuser and --testpassword that I just had been configure in mysql. I entered the site https://discussions.apple.com/thread/3932531?start=0&tstart=0&fb_source=message that is informed in README doc of ./cpan/bundle, but I already had all command line tools of xCode installed and didn't work for me too.

Why don't do sudo perl -MCPAN -e shell and to force to install Bundle::DBD::mysql? This worked well and I got the installation.

0

I got the exact same error. Actually, the issue was from my perl script. I was using:

'DBI:mysql:host=...'

and when I changed it to:

my $dsn = "DBI:MariaDB:host=$host;database=$database_name";

everything worked!

First I tried installing the mysql module, as it was suggested in one of the answers:

cpan DBD::mysql

After I installed it, it still not worked. The reason in my case was that I was actually using MariaDb. While this is a fork of MySQL, is NOT exactly the same thing. So changing that in the connection string (from the .pl file itself) fixed the issue for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.