Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

DBD::Mysql not working properly in mac OS X

by romy_mathew (Beadle)
on Nov 04, 2013 at 15:11 UTC ( #1061138=perlquestion: print w/ replies, xml ) Need Help??
romy_mathew has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to transfer the perl program running in linux to mac lion os, I had a problem in installing DBD::Mysql in mac os but on googling i found many of them with the same issue but one of the solution flueked the issue and it starts showing output. Now when i run the below code.
1 #!/usr/bin/perl 2 use strict; 3 use Data::Dumper; 4 use CGI; 5 use DBI; 6 use Template; 7 8 $| =1; 9 #print "Content-type: text/html\n\n"; 10 print "Content-type:text/html\r\n\r\n"; 11 print "html"; 12 13 my $driver = "mysql"; 14 my $database = "RON"; 15 my $dsn = "DBI:$driver:database=$database"; 16 my $userid = "root"; 17 my $password = "test"; 18 19 20 21 22 my $dbh = DBI->connect($dsn, $userid, $password ) or die $DBI::err +str; 23 my $sth=$dbh->prepare("SELECT * FROM INVOICE"); 24 $sth->execute(); 25 26 my $data = $sth->fetchall_hashref('Invoice_Number'); 27 $sth->finish(); 28 $dbh->disconnect(); 29 30 my %trend = %$data; 31 32 print Dumper(%trend); 33 34 foreach (keys %trend){ 35 36 my $invoice_nu = $trend{'Invoice_Number'}; 37 print "hello<br>\n"; 38 39 40 } 41 foreach (1..10) { 42 print "hello line $_;<br>"; 43 } 44
the above code display the putput properly in terminal but in browser it just fails to print after the DBI->connect. No lines are executed after that. I checked the err log and below is the error code mentioned. anyone please suggest me a solution for the problem.
install_driver(mysql) failed: Can't load '/Library/Perl/5.12/darwin-th +read-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: + dlopen(/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/ +mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib Referenced from: /Library/Perl/5.12/darwin-thread-multi-2level/auto/ +DBD/mysql/mysql.bundle Reason: image not found at /System/Library/Perl/5.12/darwin-thread-m +ulti-2level/DynaLoader.pm line 204. at (eval 12) line 3 Compilation failed in require at (eval 12) line 3. Perhaps a required shared library or dll isn't installed where expecte +d at /Library/WebServer/CGI-Executables/hello.pl line 22

Comment on DBD::Mysql not working properly in mac OS X
Select or Download Code
Re: DBD::Mysql not working properly in mac OS X
by daxim (Chaplain) on Nov 04, 2013 at 15:46 UTC
    Your description of how you attempted to install the module is vague, but from the results it looks like the module is not correctly installed. Try again and do it properly. Show your attempts and the errors you get.
      Below is the method I used for installing DBD::Mysql
      1. perl Makefile.PL –mysql_config=/usr/local/mysql/bin/mysql_config –t +estuser=root –testpassword=111111 I will use the following settings for compiling and testing: cflags (mysql_config ) = -I/usr/local/mysql/include -Os -g -fno-common + -fno-strict-aliasing -arch x86_64 embedded (mysql_config ) = ldflags (mysql_config ) = libs (mysql_config ) = -L/usr/local/mysql/lib -lmysqlclient -lpthread mysql_config (Users choice ) = /usr/local/mysql/bin/mysql_config nocatchstderr (default ) = 0 nofoundrows (default ) = 0 ssl (guessed ) = 0 testdb (default ) = test testhost (default ) = testpassword (User’s choice) = 111111 testsocket (default ) = testuser (User’s choice) = root 2. make 3. make test All tests successful. Files=51, Tests=1270, 22 wallclock secs ( 0.38 usr 0.16 sys + 3.51 c +usr 0.49 csys = 4.54 CPU) Result: PASS 4. sudo make install Installing /Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysq +l/mysql.bundle Appending installation info to /Library/Perl/Updates/5.12.4/darwin-thr +ead-multi-2level/perllocal.pod

        OK -- can you run something very simple, either from the debugger, or as a simple script, that just connects to the database?

        Alex / talexb / Toronto

        Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re: DBD::Mysql not working properly in mac OS X
by tangent (Curate) on Nov 04, 2013 at 16:32 UTC
    Do you have more than one version of perl installed? Type perl -V
    in the terminal and let us see the results.
      Below is the report i get on perl -V
      perl -V Summary of my perl5 (revision 5 version 12 subversion 4) configuration +: Platform: osname=darwin, osvers=12.0, archname=darwin-thread-multi-2level uname='darwin b1026.apple.com 12.0 darwin kernel version 12.0.0: t +ue may 15 23:31:29 pdt 2012; root:xnu-2050.6.70~1release_x86_64 x86_6 +4 ' config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags= +-Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc +=clang' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='clang', ccflags ='-arch i386 -arch x86_64 -g -pipe -fno-common + -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -I/usr/local/in +clude', optimize='-Os', cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing +-fstack-protector -I/usr/local/include' ccversion='', gccversion='4.2.1 Compatible Apple Clang 4.0 (tags/A +pple/clang-418.0.60)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +6 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='clang -mmacosx-version-min=10.8', ldflags ='-arch i386 -arch x +86_64 -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /usr/lib libs=-ldbm -ldl -lm -lutil -lc perllibs=-ldl -lm -lutil -lc libc=, so=dylib, useshrplib=true, libperl=libperl.dylib gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-arch i386 -arch x86_64 -bundle -undefi +ned dynamic_lookup -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_ +BIT_ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Locally applied patches: /Library/Perl/Updates/<version> comes before system perl directori +es installprivlib and installarchlib points to the Updates directory Built under darwin Compiled at Jun 20 2012 13:55:28 @INC: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4/darwin-thread-multi-2level /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12
        in location /System/Library/perl
        i see 2 version, 5.10 and 5.12.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1061138]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-12-26 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls