Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

DBD::mysql error

by liony301 (Novice)
on Mar 25, 2011 at 00:04 UTC ( #895366=perlquestion: print w/replies, xml ) Need Help??
liony301 has asked for the wisdom of the Perl Monks concerning the following question:


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/ 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/ => /lib64/ (0x00002afc8fd02000) /lib64/ (0x000000310be00000) perl perl: symbol lookup error: /usr/lib64/perl5/site_perl/5.8.8/x86_64-lin +ux-thread-multi/auto/DBD/mysql/ undefined symbol: mysql_init
        ldd doesn't fix anything, it shows you the problem, which is DBD/mysql/ isn't linked to any 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/ contains that directory. After that run ldconfig.


      Thanks Andal, I've mysql library path mentioned in mysql.conf file under /etc/ 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: -> ->

        As your ldd output shows, (the shared object belonging to DBD::mysql) hasn't been linked against, 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


    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>/ undefined symbol:

    mysql_get_server_version at 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?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-11-22 10:25 GMT
Find Nodes?
    Voting Booth?
    My code is most likely broken because:

    Results (253 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!