BurningKrome has asked for the wisdom of the Perl Monks concerning the following question:

Hey,
I had to update Perl from 5.8 to 5.14 in order to run the Date::Manip pm (which works fine) however in doing so, perl lost the ability to talk to mysql.


I installed DBD::mysql without apparent issue...however when I try to open the database I get ...

Can't locate DBD/Mysql.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.14.0/x86_64-linux /usr/local/lib/perl5/site_perl/5.14.0 /usr/local/lib/perl5/5.14.0/x86_64-linux /usr/local/lib/perl5/5.14.0 .) at ./perltest.pl line 3. BEGIN failed--compilation aborted at ./perltest.pl line 3.

If I use MCPAN to try and re-run the DBD::mysql install, I get ...

cpan11> install DBD::mysql
DBD::mysql is up to date (4.019).

I've tried using "use Mysql;" and "use DBD::mysql" in the script and both returm the appropriate "Cannot find in @INC" error.

When I try to unstall "install mysql" via CPAN I get a ...
.
.
.
dbdimp.c:3404: error: âsv_undefâ undeclared (first use in this function)
dbdimp.c: In function âmysql_db_type_info_allâ:
dbdimp.c:3903: error: âsv_undefâ undeclared (first use in this function)
make: *** dbdimp.o Error 1
CAPTTOFU/DBD-mysql-3.0008.tar.gz
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
Failed during this command:
CAPTTOFU/DBD-mysql-3.0008.tar.gz : make NO

Help :D

thanks!

Replies are listed 'Best First'.
Re: Can't locate DBD/Mysql.pm in @INC
by toolic (Bishop) on Jun 13, 2011 at 19:51 UTC
    Can't locate DBD/Mysql.pm in @INC
    It seems like you use Mysql instead of mysql somewhere in your perltest.pl code (notice the uppercase "M"). Can you show us a relevant snippet of your perltest.pl file?

    DBD::mysql shows code like:

    use DBI; my $dbh = DBI->connect('DBI:mysql:database=foo');
    That does not give me the error you get. But, if I change it to:
    use DBI; my $dbh = DBI->connect('DBI:Mysql:database=foo');
    I do get the error you get.

      This error message is also dependent on the operating system. If you're on an OS where filenames are case sensitive, the message will be that the module cannot be found in @INC. If the OS does not treat filenames with case sensitivity, the error message will report that the "object method 'driver'" cannot be found. The reason for the nuance should be fairly obvious, but I found it amusing anyway.

      On Linux, for example, the failure occurs when DBD::Mysql cannot be found. On Windows the DBD::mysql is found as DBD::Mysql, but the object method 'driver' cannot be found in reference to Mysql, because what goes on within the code is case sensitive.


      Dave

Re: Can't locate DBD/Mysql.pm in @INC
by onelesd (Pilgrim) on Jun 13, 2011 at 19:58 UTC
    Depending on how you "updated" perl, you may have more than 1 version of perl installed. Make sure that the perl (and @INC) used in your scripts is the same perl (and @INC) being referenced when you install via CPAN. Alos, I believe you need the mysql-dev libraries in order to build DBD::mysql, so check for those too. hth.
Re: Can't locate DBD/Mysql.pm in @INC
by BurningKrome (Novice) on Jun 13, 2011 at 22:08 UTC
    Hey…
    Toolic and Davido: I’ve included the entire test below (its short :D) I have tried caps and non-caps and both, I think DBD::mysql is non-caps on the “M” whereas Mysql.pm is caps. I’ve tried (I think) all iterations…but I’ll try them all again.

    My other scripts (the ones written against Perl 5.8 use the Mysql.pm module – so maybe the focus should be on trying to get it to load properly through MCPAN. I do want to have the other scripts working with Perl 5.14 (see below).

    @Onelesd: I DO in fact have two versions installed in the same system. One in /usr/bin and one in /usr/local/bin. The perl 5.14 install went there by default. I wasn;t sure if this was the issue since …

    A) The OTHER MCPAN installs went in fine (except for Mysql) and B) The paths in the @INC statement (error message) all seem to be pointing to the 5.14 paths (although I could be wrong).

    ----> I updated Perl by doing a fresh config and install from the tar.gz. Is there a way to actuall “update” 5.8?

    Thanks for the help!!

    SNIPPET #!/usr/local/bin/perl -l

    use DBD::Mysql;
    use Date::Manip;
    use Date::Manip::Date;

    # CONFIG VARIABLES
    $database = "tapestorage";
    $host = "localhost";
    $tablename = "tapes";
    $user = "root";
    $pw = "";

    $connect = Mysql->connect($host, $database, $user, $pw);
    $connect->selectdb($database);
    $mysqlquery = "SELECT * FROM tapes WHERE expdate > '$startdate' AND expdate <= '$enddate';";
    $execute = $connect->query($mysqlquery);
    while (@results = $execute->fetchrow()) {
    print fh "$results[0]|$results1|$results2";
    }

    $data = qx{rsh
    master /usr/openv/netbackup/bin/admincmd/bpmedialist -m SJ9063 -mlist -l};
    @bpmedialist = split(/ /,$data);

    $test=ParseDateString("epoch $bpmedialist6");
    print "Test = $test";
    END SNIPPET
      • It is DBD::mysql, there is no module named DBD::Mysql
      • If DBD::mysql doesn't work, you need to install DBD::mysql
      • Every time you create a post here, you get a reminder to use code tags, so follow the advice, and put your code in between code tags, its where code (and data) goes :)
        Hey...thanks for the help. I have successfully installed DBD::mysql...but all my scripts (the ones using the existing perl 5.8) use the Mysql pm (not associated with DBD)

        I was hoping to avoid having to change them all to use the DBD::mysql if I could avoid it :D
        <from BurningKrome> Ya...my scripts (perl 5.8) were all written using the Mysql.pm. When I installed 5.14...I was able to install DBD::mysql (more or less as a est) but it chokes on installing Mysql (the pm I was originally using).

        The install finds the pm, but chokes on the make.

        I've been using...
        perl -MCPAN -e shell
        and then...
        install Mysql