0

I am using RHEL 8 server where perl v5.26.0 has been installed. In my project there are lots of legacy perl modules who are using Mysql.pm as below.

require 5.004;
require Exporter;
use Mysql;

While compiling those modules, I am getting errors like,

Can't locate Mysql.pm in @INC (you may need to install the Mysql module) (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5)

I have already installed, DBD::mysql and mysql-devel.

yum install mysql-devel
DBD::mysql through cpan.

If I change the import from Mysql to DBI, the compiler does not complain. So now changing all legacy modules is time taking and risky from testing point of view.

Is there any way to downgrade the perl version to v5.16 or below? Other suggestions are much appreciated.

4
  • "Is there any way to downgrade the perl version to v5.16 or below" You should be able to install an old version like 5.12 with perlbrew, see for example this answer Commented Dec 22, 2021 at 17:57
  • DBD::mysql isn't Mysql. I have no idea what Mysql is, but it's not on CPAN, and it's not part of Perl. Is it a module installed in the same dir as the script? If so, this question is a duplicate of this one Commented Dec 22, 2021 at 18:41
  • While doing through perlbrew, it opens up a new shell in root. However my perl scripts would be executed by apache httpd through CGI. Commented Dec 23, 2021 at 2:43
  • @PrashantaKumarPal I think apache uses the shebang line to select the perl it will use, see this reference. Can you try modify the shebang to the absolute path of the perlbrew installed perl? Commented Dec 23, 2021 at 7:29

1 Answer 1

1

Mysql is a very old interface to MySQL databases from back in the days before DBI. It has no connection at all to DBI::mysql. The last version on CPAN is over twenty years ago.

You could try to install that CPAN distribution on your server (but, to be honest, the CPAN Testers results don't look encouraging).

Your best bet (and, yes, it will probably be a bit of work) is to rewrite your code to use DBI::mysql instead. Maybe you can write your own shim in a module called Mysql that converts the old Mysql-style calls to DBI::mysql ones.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.