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

I have a subroutine that opens two mysql databases that is shared by multiple scripts on a stand-alone Debian 8 server. It was working in all the scripts (around 14) but recently stopped working in just one.

The error is:

install_driver(mysql) failed: Can't locate loadable object for module +DBD::mysql in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.3 +8.2/x86_64-linux /usr/local/lib/perl5/site_perl/5.38.2 /usr/local/lib +/perl5/5.38.2/x86_64-linux /usr/local/lib/perl5/5.38.2) at (eval 5) l +ine 3. Compilation failed in require at (eval 5) line 3. Perhaps a module that DBD::mysql requires hasn't been fully installed

I don't want to force reinstall the DBD::mysql module for fear of breaking all the scripts that are not receiving the error.

I tried running just the sub by itself and I get the error. I tried moving the script to a folder where a not-broken script resides. Same error.

Any thoughts?

Replies are listed 'Best First'.
Re: DBD mysql
by Danny (Chaplain) on Sep 24, 2024 at 21:19 UTC
    That means none of these files exist
    /usr/local/lib/perl5/site_perl/5.38.2/x86_64-linux/DBD/mysql.pm /usr/local/lib/perl5/site_perl/5.38.2/DBD/mysql.pm /usr/local/lib/perl5/5.38.2/x86_64-linux/DBD/mysql.pm /usr/local/lib/perl5/5.38.2/DBD/mysql.pm
    Can you verify that by manually checking?

    If it's not there you probably have something wrong with your @INC variable.

    Update: Looking more closely at the error it seems to be missing the shared object file like:
    /usr/local/lib/perl5/site_perl/5.38.2/x86_64-linux/auto/DBD/mysql/mysq +l.so
    Maybe try find /usr/local/lib/perl5 | grep mysql, to see all the mysql stuff.

      Some errors pertaining to .so files can refer to the file itself, or to a dependency. So if DBD/mysql/mysql.so exists, it could be that it's a dependency that's missing. Maybe the underlying MySQL library was updated and it now has a different name?

      Re-installing DBD::mysql should fix the issue. Either that or DBD::mysql is being installed in a "non-standard" location and Perl wasn't told to look there.

        If I reinstall DBD::mysql am I risking breaking all my running scripts that use it? If those scripts fail, my business would suffer a big loss of income. Most of my billable activities are fed by these scripts. Of the many things I don't understand, why did this just break when there were zero changes on the server? And, why do they all work in html but just not on the command line?
      mysql.pm exists in these: /usr/local/lib/perl5/site_perl/5.38.2/DBD/mysql.pm /usr/local/lib/perl5/5.38.2/x86_64-linux/DBD/mysql.pm /usr/local/lib/perl5/5.38.2/DBD/mysql.pm
        In each of those three locations check if DBD/mysql/mysql.so exists. If it exists in some but not others, in the paths where it doesn't exist move your mysql.pm to some other name like "mv mysql.pm mysql.pm.save" and see if that fixes it.
        Thank you Danny, I'm lost in the threads but all of the scripts run in html and also in the shell except one. Which ran without a problem 15 times. Now, on the 16th try is when the message shows. The server is dedicated and purposely has had zero upgrades because upgrades tend to break things. I tried running as root and also as admin. I think html runs as wheel but I'm not sure. All the scripts are 755 permission. I think the html user is www-data. www-data 31575 0.0 0.3 98448 7588 ? S 06:25 0:08 /usr/sbin/apache2 -k start
      root@localhost:/var/www/cgi-bin/plivo/google-ads-perl# find /usr/local/lib/perl5 | grep mysql /usr/local/lib/perl5/site_perl/5.38.2/x86_64-linux/DBD/mysql.pm /usr/local/lib/perl5/site_perl/5.38.2/DBD/mysql.pm /usr/local/lib/perl5/site_perl/5.38.2/DBD/mysql.pl /usr/local/lib/perl5/5.38.2/x86_64-linux/DBD-save/mysql.pm /usr/local/lib/perl5/5.38.2/DBD/mysql.pm
        Since auto/DBD/mysql/mysql.so seems to be missing you should probably reinstall DBD::mysql. The find/grep should give you a list something like:
        /.../5.38.0/lib/site_perl/5.38.0/x86_64-linux-thread-multi/auto/DBD/my +sql /.../5.38.0/lib/site_perl/5.38.0/x86_64-linux-thread-multi/auto/DBD/my +sql/mysql.so /.../5.38.0/lib/site_perl/5.38.0/x86_64-linux-thread-multi/auto/DBD/my +sql/.packlist /.../5.38.0/lib/site_perl/5.38.0/x86_64-linux-thread-multi/Bundle/DBD/ +mysql.pm /.../5.38.0/lib/site_perl/5.38.0/x86_64-linux-thread-multi/DBD/mysql /.../5.38.0/lib/site_perl/5.38.0/x86_64-linux-thread-multi/DBD/mysql/I +NSTALL.pod /.../5.38.0/lib/site_perl/5.38.0/x86_64-linux-thread-multi/DBD/mysql/G +etInfo.pm /.../5.38.0/lib/site_perl/5.38.0/x86_64-linux-thread-multi/DBD/mysql.p +m
      I must have mis-stated. These locations are where mysql.pm does exist. /usr/local/lib/perl5/site_perl/5.38.2/x86_64-linux/DBD/mysql.pm /usr/local/lib/perl5/site_perl/5.38.2/DBD/mysql.pm /usr/local/lib/perl5/5.38.2/x86_64-linux/DBD/mysql.pm /usr/local/lib/perl5/5.38.2/DBD/mysql.pm
        I understood, but auto/DBD/mysql/mysql.so doesn't seem to be there according to your find/grep. Thus, you should probably try to reinstall DBD::mysql.
Re: DBD mysql
by swl (Prior) on Sep 25, 2024 at 01:28 UTC

    Use the otool utility on mysql.so and similar files. This will show all the dependencies it is expecting, and should highlight the ones it cannot find.

    I'm not in front of a mac at the moment so cannot test, but it should be something like this:

    otool -l /usr/local/lib/perl5/site_perl/5.38.2/x86_64-linux/auto/DBD/mysql/mysql.so

    An example with output is at this link: https://forums.developer.apple.com/forums/thread/705281.