1

I have Perl installed on Linux RHEL: perl -v

This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64-linux-thread-multi

When I run command to see Perl modules installed:

find `perl -e 'print "@INC"'` -name '*.pm' -print

I can see for DBI:

/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/DBI/DBD/Metadata.pm
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/DBI/DBD/SqlEngine.pm
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/DBD/mysql/GetInfo.pm
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/DBD/mysql.pm
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/Bundle/DBD/mysql.pm

And MySQL installed and running:

Server version: 5.6.26 MySQL Community Server (GPL)

I have 2 lines of code in a Perl Script:

use DBI;
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost","root", "pass");

Error that I see is:

$ perl mysql.pl
install_driver(mysql) failed: Can't load '/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.15: cannot open shared object file: No such file or directory at /mu/apps/perl/5.12.2-gcc443-rhel5-64/lib/DynaLoader.pm line 200.
 at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at mysql.pl line 2
$

I verified with YUM:

$ sudo yum install perl-DBD-MySQL
Setting up Install Process
Package perl-DBD-MySQL-4.013-3.el6.x86_64 already installed and latest version
Nothing to do
$

This is the list of /usr/lib64/mysql :

$ pwd
/usr/lib64/mysql

$ ls -lrth
/usr/lib64/mysql

total 14M
-rwxr-xr-x 1 root root 8.6M Jul 14 17:47 libmysqlclient.so.18.1.0*
-rwxr-xr-x 1 root root 2.7M Jul 14 17:49 libmysqlclient.so.16.0.0*
-rwxr-xr-x 1 root root 2.7M Jul 14 17:49 libmysqlclient_r.so.16.0.0*
lrwxrwxrwx 1 root root   24 Jul 27 18:23 libmysqlclient.so.18 -> libmysqlclient.so.18.1.0*
lrwxrwxrwx 1 root root   24 Jul 27 18:23 libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0*
lrwxrwxrwx 1 root root   20 Jul 27 18:23 libmysqlclient_r.so.18 -> libmysqlclient.so.18*
lrwxrwxrwx 1 root root   24 Jul 27 18:23 libmysqlclient.so.16 -> libmysqlclient.so.16.0.0*
lrwxrwxrwx 1 root root   26 Jul 27 18:23 libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0*
drwxr-xr-x 3 root root 4.0K Jul 27 18:23 plugin/
$

What should I do next? How to configure this problematic (libmysqlclient.so.15) or there is some other problem?

Joe
  • 11,983
  • 31
  • 109
  • 183
  • Is the MySQL client installed (`sudo yum install mysql.x86_64`, perhaps)? – mob Sep 02 '15 at 15:31
  • Is that the system perl or did you install your own? Last I checked, EL 6 came with Perl 5.10.1, but maybe they've upgraded since then. – ThisSuitIsBlackNot Sep 02 '15 at 15:37
  • $ sudo yum install mysql.x86_64 Setting up Install Process Package mysql-5.1.73-5.el6_6.x86_64 is obsoleted by mysql-community-client-5.6.26-2.el6.x86_64 which is already installed Nothing to do $ – Joe Sep 02 '15 at 15:41
  • what's `rpm -ql perl-DBD-MySQL` output? – ngn999 Sep 02 '15 at 15:43
  • There is shared Perl library across company network.. System Admins maintain that. Most Linux servers that I just checked have this version of Perl (5.12). – Joe Sep 02 '15 at 15:44
  • $ rpm -ql perl-DBD-MySQL /usr/lib64/perl5/Bundle /usr/lib64/perl5/Bundle/DBD /usr/lib64/perl5/Bundle/DBD/mysql.pm /usr/lib64/perl5/DBD /usr/lib64/perl5/DBD/mysql /usr/lib64/perl5/DBD/mysql.pm /usr/lib64/perl5/DBD/mysql/GetInfo.pm /usr/lib64/perl5/DBD/mysql/INSTALL.pod /usr/lib64/perl5/auto/DBD /usr/lib64/perl5/auto/DBD/mysql /usr/lib64/perl5/auto/DBD/mysql/mysql.so – Joe Sep 02 '15 at 15:45
  • /usr/share/doc/perl-DBD-MySQL-4.013 /usr/share/doc/perl-DBD-MySQL-4.013/ChangeLog /usr/share/doc/perl-DBD-MySQL-4.013/INSTALL.html /usr/share/doc/perl-DBD-MySQL-4.013/README /usr/share/doc/perl-DBD-MySQL-4.013/TODO /usr/share/man/man3/Bundle::DBD::mysql.3pm.gz /usr/share/man/man3/DBD::mysql.3pm.gz /usr/share/man/man3/DBD::mysql::INSTALL.3pm.gz $ – Joe Sep 02 '15 at 15:45
  • Oh, the system perl should works. Have a try. – ngn999 Sep 02 '15 at 15:48
  • @Joe I think you'll have to get your sysadmin to install your Perl modules. You're running perl 5.12.2, but yum uses the system perl, which I assume is 5.10.1. Note how all the components for perl-DBD-MySQL are installed in `/usr/lib64/perl5`, not `/mu/sdk/perl` – ThisSuitIsBlackNot Sep 02 '15 at 15:49
  • @ngn999 How can I try 'system perl' ? What should I type? – Joe Sep 02 '15 at 15:49
  • @Joe "How can I try 'system perl'" Change your shebang to `#!/usr/bin/perl` (although that won't work so well if you have environment variables like `PERL5LIB` set and pointing to your perl 5.12.2 installation). – ThisSuitIsBlackNot Sep 02 '15 at 15:51
  • /usr/bin/perl script.pl? – ngn999 Sep 02 '15 at 15:52
  • /usr/bin/perl worked! I am so beginner in this.. Did not realized there might be 2 versions of Perl installed on this server.. $ /usr/bin/perl -v This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi – Joe Sep 02 '15 at 15:56
  • (adding shebang #!/usr/bin/perl at the beginning of script did not work but at least have a workaround with /usr/bin/perl myscript.pl) – Joe Sep 02 '15 at 15:59
  • @Joe If you invoke your script like this: `perl myscript.pl` then the shebang will be ignored. If you invoke it like this: `/path/to/myscript.pl` then the shebang is used. – ThisSuitIsBlackNot Sep 02 '15 at 16:00
  • Are you supposed to be doing your development work with the shared perl? If so, it would be better to ask your sysadmin to install the modules you need so that you're using the same version of perl as the rest of your company. – ThisSuitIsBlackNot Sep 02 '15 at 16:02
  • 1
    To be honest - I just got the server and saying 'everything is installed there'. Was not sure there will be 2 different Perl version and possibly different modules installed.. But thank you guys, this was simple but saved me several hours of tumbling around! :) – Joe Sep 02 '15 at 16:05

0 Answers0