DBD-mysql installed ,but still error "install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC"
Asked Answered
N

6

26

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.

Nardoo answered 17/6, 2013 at 9:43 Comment(0)
V
69

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.

Viscounty answered 17/6, 2013 at 12:23 Comment(6)
A big thank you, yum worked for my CentOS 5.x box.Circumvallate
worked also for me under ubuntu 16.04 where installing from cpan did not. Thanks!Callous
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 alreadyDrue
@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.Viscounty
could you please look once into my problem on below link, it will be really helpful #54814243Drue
yum worked for me in centos 7Life
K
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

Kujawa answered 17/6, 2013 at 9:54 Comment(7)
perl Makefile.PL --mysql_config=/usr/bin/mysql_configNardoo
@user2492829, What is that?Kujawa
I can't install "cpan>install DBD::mysql",because not connected in my virtual machine.This is the install command to untar fileNardoo
So use the four command process described in the Synopsis of the file I linked.Kujawa
No, that doesn't install anything. That just generates the Makefile you will use to install the module.Kujawa
how to install with this makefile.?cmake?Nardoo
As I mentioned, the commands are listed in the Synopsis of the file I linked. I've even added them to my answer already.Kujawa
A
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
Adrell answered 28/11, 2017 at 9:53 Comment(0)
M
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)

Mariammarian answered 5/5, 2014 at 9:28 Comment(1)
It's ridiculous to blindly use --force!Kujawa
N
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.

Nugget answered 18/9, 2013 at 14:46 Comment(0)
T
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

Telespectroscope answered 10/3, 2023 at 14:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.