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.

Shadow
  • 33,525
  • 10
  • 51
  • 64
  • *"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](https://stackoverflow.com/a/57407598/2173773) answer – Håkon Hægland Dec 22 '21 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](https://stackoverflow.com/q/46549671/589924) – ikegami Dec 22 '21 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. – Prashanta Kumar Pal Dec 23 '21 at 02:43
  • @PrashantaKumarPal I think apache uses the shebang line to select the perl it will use, see [this](https://docstore.mik.ua/orelly/linux/apache/ch04_02.htm) reference. Can you try modify the shebang to the absolute path of the perlbrew installed perl? – Håkon Hægland Dec 23 '21 at 07:29

1 Answers1

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.

Dave Cross
  • 68,119
  • 3
  • 51
  • 97