Proper Technique for DBD::mysql install

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Just wondering........

    I am compiling the DBD:mysql perl modules on a Solaris 10 sparc,
machine and seem to have run into an common issue.

    Here is the scenario, Solaris 10 comes with mysql 4 installed in /
usr/sfw,  but I need the mysql 5 client libraries to make remote
connections to a remote mysql 5 database.  So I installed mysql 5 in
another location. (down /export, because the location is
automounted.)  I then compiled the DBD::mysql perl module like so:

perl Makefile.PL --testdb=remote_testdb  --testuser=remote_user --
testpassword=remote_passwd --testhost=remote_host --testport=3306 --

mysql_config returns:

Usage: ./mysql_config [OPTIONS]
        --cflags        [-I/export/software/mysql-5/include  -g -
        --include      [-I/export/software/mysql-5/include]
        --libs             [-L/export/software/mysql-5/lib -
lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm]
        --libs_r         [-L/export/software/mysql-5/lib -
lmysqlclient_r -lz -lpthread -lthread -lposix4 -lgen -lsocket -lnsl -
lm  -lpthread -lthread]
        --socket         [/tmp/mysql.sock]
        --port           [0]
        --version        [5.0.67]
        --libmysqld-libs [-L/export/software/mysql-5/lib -lmysqld -lz -
lpthread -lthread -lposix4 -lgen -lsocket -lnsl -lm  -lpthread -
lthread   -lrt]

I am using gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath) (which
was also used to build the perl I am using, /export/software/perl/

When I run a make I get the following warning:

Warning: duplicate function definition 'do' detected in mysql.xs, line
Warning: duplicate function definition 'rows' detected in mysql.xs,
line 650

and when I run a make test:

ERROR: install_driver(mysql) failed: Can't load './DBD-mysql-4.010/

I know what the problem is... the can't find the file.

so I have to export LD_LIBRARY_PATH to /export/software/mysql-5/lib.
Then the make and make test run properly after that.

But if I run a simple DBI connect script I get:

install_driver(mysql) failed: Can't load '/export/software/perl/v5.8.4/
lib/site_perl/5.8.4/sun4-solaris/auto/DBD/mysql/' for module
DBD::mysql: perl: fatal: open failed:
No such file or directory at /export/software/perl/v5.8.4/lib/5.8.4/
sun4-solaris/ line 230.

but yet again if I set my LD_LIBRARY_PATH it runs correctly.

     So after spending the past couple of days "googling,yahooing,
etc" it seems a possible solution is to have the script like so:

  unless ($ENV) {
    $ENV = "/export/software/mysql-5/lib";
    $ENV = 1;
    exec 'env',$0,@ARGV;

use strict;
use warnings;
use DBI;

my $db_user   = 'remote_user';
my $db_pass   = 'remote_passwd';
my $db_host   = 'remote_host';
my $db_name   = 'remote_db';
my $db_type   = 'mysql';
my $db_port   = '3306';
my $db_dsn    = "DBI:$db_type:$db_name:$db_host:$db_port";

my $db_con  = DBI->connect($db_dsn, $db_user, $db_pass)
                  || die "Failed DB Connection: $DBI::errstr\n";


but it seems like a 1/2 a55ed solution.    I would think I should be
able to compile the DBD::mysql module to have the so always look in
the directory I tell it to for the mysql client and not rely on
1 for it's library path or LD_LIBRARY_PATH.

I'm sure other people have had similar experiences.  Is this the way
to go, or is there a better way to do it?


Site Timeline