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

Hi Monks,

I just installed mySQL on a sparc running Solaris 8 and created my database.

I then installed the DBI and DBD::mysql modules using CPAN, they compiled but failed a couple of tests, they still installed however.

Then i wrote a small sample script:
#!/usr/bin/perl use DBI; ($pass = shift) || die Useage(); print "Enter Listname:"; my $listname = <STDIN>; $db = "nMail"; $sock = "/tmp/mysql.sock"; $user = "nmail"; $dsn = "DBI:mysql:$db;mysql_socket=$sock"; $dbh = DBI->connect($dsn,$user,$pass); $sth = $dbh->prepare("INSERT INTO nMail.ML_Lists (Mname) VALUE +S ('$listname')"); $sth->execute() || die "Error: Could not create mailing list $ +listname\n"; $sth->finish(); $dbh->disconnect(); sub Useage { return " Error Invalid Arguments, Useage: $0 <password> "; }
However after executing the script i get the following error:
bash-2.03$ ./add_list.pl <*password-cut*> Enter Listname:Test ld.so.1: /usr/bin/perl: fatal: relocation error: file /usr/local/lib/p +erl5/site_perl/5.6.1/sun4-solaris/auto/DBD/mysql/mysql.so: symbol mys +ql_init: referenced symbol not found Killed bash-2.03$
Does anyone have any idea what may be causing this error? Or any ideas how to fix it?

Thanks a lot

Neil Archibald - /dev/IT -

Replies are listed 'Best First'.
Re: Database access error.
by Anonymous Monk on Jun 27, 2003 at 03:10 UTC

    It looks like you may have a library compatibility problem.

    Did you compile the module? If the C compiler you used for this module was different from the one used to compile Perl and MySQL, then you should get the sources for both and recompile them. :(

    From the DBD::mysql installation doc

    A C compiler is only required, if you install from source. In most cases there are binary distributions of DBD::mysql available. However, if you need a C compiler, make sure, that it is the same C compiler that was used for compiling Perl and MySQL! Otherwise you will almost definitely encounter problems because of differences in the underlying C runtime libraries.

    In the worst case, this might mean to compile Perl and MySQL yourself. But believe me, experience shows that a lot of problems are fixed this way.

      One again thanks a lot for posting, just compiled perl myself and DBI / DBD::mysql compiled perfectly :)

      Neil Archibald
      - /dev/IT -
      Thanks for your input,

      Argh i'm sure this would fix alot of problems but i'm really scared to do this as i'm new to the solaris environment and this is a very important box to my work.

      Breaking this box could very well cost me my job

      :-(

      The C compiler isn't even in the path so i'm not sure how i would be at compiling perl.

      Neil Archibald - /dev/IT -
Re: Database access error.
by cchampion (Curate) on Jun 27, 2003 at 09:21 UTC

    I am glad that you've solved your problem.

    On a side note, I would like to offer some thoughts on your script, if you don't mind.

    First of all, the Monastery chant. use strict and warnings, so that you can catch the errors before they catch you.

    Then, you are getting a value from standard input without any processing. You should at least use chomp to remove the newline at the end of the string, and then check that your listname doesn't contain any characher that later on may make your life difficult.

    Furthermore, a call to $sth->finish is only needed when you are fetching records. For data manipulation commands such as INSERT or UPDATE, you don't need it.

    Cheers

Re: Database access error.
by Anonymous Monk on Jun 27, 2003 at 02:57 UTC

    Which tests did not pass?

    If a test fails, it means that something went wrong.

      I just tried to recompile the modules DBI and DBD::mysql to see the output.

      When compiling DBI, the following tests did not pass
      t/15array..............FAILED test 18 t/zz_15array_pp........FAILED te +st make: Fatal error: ... Command failed for target `test_dynamic' /usr/ccs/bin/make test -- NOT OK Running make install make test had returned bad status, won't install without force 18
      When compiling DBD::mysql however almost all tests failed
      t/mysql2...........dubious + Test returned status 255 (wstat 65280, 0xff00) Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t/00base.t 255 65280 5 4 80.00% 4-5 t/10dsnlist.t 255 65280 9 18 200.00% 1-9 t/20createdrop.t 255 65280 5 10 200.00% 1-5 t/30insertfetch.t 255 65280 11 22 200.00% 1-11 t/40bindparam.t 255 65280 28 56 200.00% 1-28 t/40blobs.t 255 65280 11 22 200.00% 1-11 t/40listfields.t 255 65280 16 32 200.00% 1-16 t/40nulls.t 255 65280 11 22 200.00% 1-11 t/40numrows.t 255 65280 25 50 200.00% 1-25 t/50chopblanks.t 255 65280 35 70 200.00% 1-35 t/50commit.t 255 65280 30 60 200.00% 1-30 t/ak-dbd.t 255 65280 90 180 200.00% 1-90 t/akmisc.t 255 65280 351 702 200.00% 1-351 t/dbdadmin.t 255 65280 21 42 200.00% 1-21 t/insertid.t 255 65280 12 24 200.00% 1-12 t/mysql.t 255 65280 68 136 200.00% 1-68 t/mysql2.t 255 65280 ?? ?? % ?? 1 test skipped. Failed 17/18 test scripts, 5.56% okay. 725/728 subtests failed, 0.41% +okay. *** Error code 2
      Sorry i didn't provide enough information. I don't really understand these tests.

      Are these errors because DBD::mysql requires DBI to be compiled correctly and DBI has an error compiling the 15array section? Or am i way off?

      Neil Archibald - /dev/IT -