Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Having the following error while trying to execute a perl script(For LVM backup). Seeing some DBD module is missing. How would I resole it ?

[root@localhost mylvmbackup-0.13]# ./mylvmbackup 
20120804 02:26:06 Info: Connecting to database...
Uncaught exception from user code:
        install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/share/mylvmbackup /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at (eval 17) 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 ./mylvmbackup line 202
 at /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/DBI.pm line 756
        DBI::install_driver('DBI', 'mysql') called at /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/DBI.pm line 600
        DBI::connect('DBI', 'DBI:mysql:database=mysql;mysql_read_default_group=client', 'root', '') called at ./mylvmbackup line 202

When I tried to resolve it by installing perl-DBD-MYSQL it gives some conflict as well ?

yum install perl-DBD-MySQL
--> Finished Dependency Resolution
mysql-5.0.95-1.el5_7.1.x86_64 from updates has depsolving problems
  --> mysql conflicts with MySQL-server-community
Error: mysql conflicts with MySQL-server-community
share|improve this question
add comment

2 Answers

It appears you've installed incompatible RPM packages for MySQL from a third party source. Probably these came from mysql.org. Unfortunately they aren't well integrated and cause problems like this.

Currently the best integrated current MySQL RPM packages that I'm aware of are those provided in the remi repository. Using these packages will prevent problems like this in future.

share|improve this answer
add comment

Normally I don't advise to override rpm dependencies. I advise you to attempt to stay within the confines of completely managed package system (i.e. rpm installs and controls everything).

People who build mysql packages (should) always also build a separate shared libs package which contains "compatible shared libraries". What this means is that they know they are building a version of mysql which is likely not going to directly work with your distribution provided binaries, so they also build some extra (usually older) mysql shared libs that will provide the correct version shared libraries your distro provided binaries are expecting. Find and download the MySQL-shared-compat rpm that is the same version you installed from the mysql.org site, then install it. Test your script, if it works, you're done.

Now, how to possibly break your perl DBI system:

Having said all that, I have been in this exact situation before where I was experimenting with other mysql packages other than those provided by CentOS proper. yum won't install this perl module due to unmet dependencies, but these dependencies are usually just naming conventions. In most cases the actual shared library it needs is present and usable. You can force rpm to overlook those dependencies by downloading the perl DBD mysql rpm from a mirror and running:

rpm -ivh --force perl-DBD-MySQL*.rpm

Then perform a quick test to see if it has a problem with the shared libs by running the following two commands:

# Should print out nothing, nor any errors
CentOS58[root@stats ~]# perl -e 'use DBD::mysql'
CentOS58[root@stats ~]#

CentOS58[root@stats ~]# ldd /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql/mysql.so
libmysqlclient.so.15 => /usr/lib64/mysql/libmysqlclient.so.15 (0x00002aaaaacd6000)
<snip>

If both of those work properly, then it's likely your script will run just fine. If they don't work properly, you can return your system to the state it was by just deleting (manually) the rpm, in nearly the same way you installed it:

# May need to add --nodeps and/or --force
rpm -e perl-DBD-MySQL
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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