Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

DBD::mysql error

by liony301 (Novice)
on Mar 25, 2011 at 00:04 UTC ( [id://895366]=perlquestion: print w/replies, xml ) Need Help??

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

Hi,

I've installed mysql version 5.1.55 from the source. Installed perl rpm version- perl-5.8.8-32.el5_5.2.


I've configured perl modules using cpan command -
cpan -i Bundle::DBD::mysql

Installed modules are:
DBD::mysql DBI ExtUtils::MakeMaker Perl Term::ReadKey Test::Simple

Now I've one script to check if I could connect to mysql. Here is the script which I used to test -

#!/usr/bin/perl -w use strict; use warnings; use DBI; my $db="test"; my $host="localhost"; my $user="test"; my $password="test"; #connect to MySQL database my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host",$user,$pas +sword) or die "Can't connect to database: $DBI::errstr\n"; #disconnect from database $dbh->disconnect or warn "Disconnection error: $DBI::errstr\n"; exit;
However on execution I get following error -
perl: symbol lookup error: /usr/lib64/perl5/site_perl/5.8.8/x86_64-lin +ux-thread-multi/auto/DBD/mysql/mysql.so: undefined symbol: mysql_init
It would be really great if you can guide me to resolve this issue.

Replies are listed 'Best First'.
Re: DBD::mysql error
by Anonymous Monk on Mar 25, 2011 at 00:18 UTC
      Thanks for quick response.
      Result looks same ever after doing ldd.
      ldd /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DB +D/mysql/mysql.so libc.so.6 => /lib64/libc.so.6 (0x00002afc8fd02000) /lib64/ld-linux-x86-64.so.2 (0x000000310be00000) perl perl_mysql.pl perl: symbol lookup error: /usr/lib64/perl5/site_perl/5.8.8/x86_64-lin +ux-thread-multi/auto/DBD/mysql/mysql.so: undefined symbol: mysql_init
        ldd doesn't fix anything, it shows you the problem, which is DBD/mysql/mysql.so isn't linked to any libmysql64.so or the like, mysql_init is defined in libmysql
Re: DBD::mysql error
by andal (Hermit) on Mar 25, 2011 at 08:10 UTC

    Check into which directory MySQL libraries were installed, probably somewhere in /usr/local tree since you've installed if from source. Make sure that /etc/ld.so.conf contains that directory. After that run ldconfig.

    HTH

      Thanks Andal, I've mysql library path mentioned in mysql.conf file under /etc/ld.so.conf.d/ directory.


      Here are the content -
      cat mysql.conf /app/mysql/lib/mysql/

      Here is the specific output for mysql after I ran ldconfig -

      sudo /sbin/ldconfig -vv /app/mysql/lib/mysql: libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0 libmysqlclient.so.16 -> libmysqlclient.so.16.0.0

        As your ldd output shows, mysql.so (the shared object belonging to DBD::mysql) hasn't been linked against libmysqlclient.so, so no messing with dynamic loader search paths or ldconfig is going to help here, because the loader doesn't even look for the latter library...  (it's kind of like fiddling with @INC without having use Module in the code).

        Most likely, this is the result of something having gone wrong while building DBD::mysql — presumably the mysql library and/or the header files were not found at build time.  So you'll have to rebuild the module, making sure the lib/header files are found this time.  See the INSTALL file for how to do a manual installation and specify the respective options to Makefile.PL that tell the build process where to find things.

Re: DBD::mysql error
by Anonymous Monk on Mar 25, 2011 at 05:01 UTC
    Try... /sbin/ldconfig On Linux systems after installing a library you may have to rebuild the loader cache. Maybe the RPM does it; maybe not.

      I appreciate your efforts in helping me.
      I tried that too, but to no help.

Re: DBD::mysql error
by yerbol (Initiate) on May 12, 2011 at 21:49 UTC

    Hi,

    I am trying to install DBD::mysql, but having test errors.

    t/00base ...........NOK 2# Failed test 'use DBD::mysql;'

    # at t/00base.t line 21.

    # Error: Cant load '<dir>/mysql.so: undefined symbol:

    mysql_get_server_version at DynaLoader.pm line 230

    # at (eval 7) line 2

    Failed--Further testing stopped: Unable to load DBD::mysql

    make: *** test_dynamic Error 9

    /usr/bin/make test -- NOT OK

    make test had returned bad status, won't install without force

    I am using Fedora Core 8 with 32 bit kernel.

    DBI 1.616

    perl 5.8.8

    please, any suggestions?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://895366]
Approved by davies
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-18 22:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found