Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
"be consistent"
 
PerlMonks  

DBD::mysql won't install

by 7stud (Deacon)
on Jan 06, 2013 at 09:07 UTC ( #1011855=perlquestion: print w/ replies, xml ) Need Help??
7stud has asked for the wisdom of the Perl Monks concerning the following question:

Mac OSX 10.6.8

64 bit mysql

~$ perl -v This is perl 5, version 16, subversion 0 (v5.16.0) built for darwin-2l +evel
~$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 48 Server version: 5.5.28 MySQL Community Server (GPL) Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights res +erved. mysql> exit Bye
~$ sudo cpan DBD::mysql Password: CPAN: Storable loaded ok (v2.34 Reading '/Users/7stud/.cpan/Metadata' Database was generated on Sat, 05 Jan 2013 19:06:47 GMT CPAN: YAML loaded ok (v0.84) Reading 34 yaml files from /Users/7stud/.cpan/build/ CPAN: Time::HiRes loaded ok (v1.9725) ..................DONE Restored the state of none (in 0.5013 secs) Running install for module 'DBD::mysql' Running make for C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz Has already been unwrapped into directory /Users/7stud/.cpan/build/D +BD-mysql-4.022-LOppYe CPAN: Parse::CPAN::Meta loaded ok (v1.4402) CPAN: CPAN::Meta loaded ok (v2.120630) CPAN: Module::CoreList loaded ok (v2.79) Has already been made Running make test PERL_DL_NONLAZY=1 /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/bin/pe +rl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/ +arch')" t/*.t t/00base.t .................. 1/6 # Failed test 'use DBD::mysql;' # at t/00base.t line 21. # Tried to use 'DBD::mysql'. # Error: Can't load '/Users/7stud/.cpan/build/DBD-mysql-4.022-LOp +pYe/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlo +pen(/Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/arch/auto/DB +D/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.18.dylib # Referenced from: /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/b +lib/arch/auto/DBD/mysql/mysql.bundle # Reason: image not found at /Users/7stud/perl5/perlbrew/perls/perl- +5.16.0/lib/5.16.0/darwin-2level/DynaLoader.pm line 194. # at (eval 7) line 2. # Compilation failed in require at (eval 7) line 2. # BEGIN failed--compilation aborted at (eval 7) line 2. Bailout called. Further testing stopped: Unable to load DBD::mysql FAILED--Further testing stopped: Unable to load DBD::mysql make: *** [test_dynamic] Error 255 CAPTTOFU/DBD-mysql-4.022.tar.gz /usr/bin/make test -- NOT OK //hint// to see the cpan-testers results for installing this module, t +ry: reports CAPTTOFU/DBD-mysql-4.022.tar.gz Running make install make test had returned bad status, won't install without force ~$
~$ echo $DYLD_LIBRARY_PATH /usr/local/mysql/lib
~$ cd /usr/local/mysql/lib /usr/local/mysql/lib$ ls libmysqlclient.18.dylib libmysqlclient_r.dylib libmysqlclient.a libmysqld-debug.a libmysqlclient.dylib libmysqld.a libmysqlclient_r.18.dylib libmysqlservices.a libmysqlclient_r.a plugin /usr/local/mysql/lib$

Comment on DBD::mysql won't install
Select or Download Code
Re: DBD::mysql won't install
by Anonymous Monk on Jan 06, 2013 at 09:13 UTC
Re: DBD::mysql won't install
by Anonymous Monk on Jan 06, 2013 at 23:08 UTC

    How about ldd (or ?otool) mysql.bundle and libmysqlclient.18.dylib ? That way you know what if anything is missing from DYLD_LIBRARY_PATH ?

    Are you mixing 32bit/64bit mysql libraries? export VERSIONER_PERL_PREFER_32_BIT=no ? export VERSIONER_PERL_PREFER_32_BIT=yes ?

      Thanks for the response.

      1) I don't know where to find mysql.bundle. The following yields no results:

      /usr/local/mysql$ sudo find . -name mysql.bundle

      And I've never used otool before. You'd have to tell me what flags to run otool with to get the information you want.

      2) Those environment variables don't show up when I do:

      $ env | sort

        Me neither, I'm on windows

        Bye

Re: DBD::mysql won't install
by Mr. Muskrat (Abbot) on Jan 07, 2013 at 21:50 UTC

      Thanks for the response.

      Did you read README.OSX?

      Now I have. However, I'm not using Lion, and I'm using an earlier version of Xcode, 3.2.2, and there is no Downloads tab/choice/button in my Xcode's Preferences pane.
Re: DBD::mysql won't install
by 7stud (Deacon) on Jan 15, 2013 at 10:29 UTC

    I finally got DBD::mysql installed, and I was able to run a test program successfully. Here is what I did:

    1) Repaired permissions. The directory /Users/7stud/.cpan is the top of the directory hierarchy that perlbrew uses to install my modules. I must have done a:

    $ sudo cpan Some::Module

    at some point because some of the sub directories under /Users/7stud/.cpan were owned by root--because they were created by root. However, all the sub directories need to be owned by 7stud in order for me to install modules without using sudo--otherwise I get Permission Denied errors when installing some modules. To change all the permissions in the .cpan directory and all sub directories, I used this command:

    /Users/7stud/.cpan$ sudo chown -R 7stud .

    Note the dot at the end of the command, which denotes the current directory. That command says to recursively change ownership of all the files in the current directory and below to the user 7stud, which is as it should be.

    2) Fixed libmysqlclient.18.dylib problem. At this link, there is a tip about curing the libmysqlclient.18.dylib problem noted in the output:

    Library not loaded: libmysqlclient.18.dylib

    At the link, it says that if you do this:

    $ otool -D `mdfind libmysqlclient.18.dylib`

    (Note the backticks) then the output will indicate something is not right. To fix the problem, the person says to do this:

    $ sudo install_name_tool -id /usr/local/mysql-5.5.28-osx10.6-x86_64/li +b/libmysqlclient.18.dylib /usr/local/mysql-5.5.28-osx10.6-x86_64/lib/libmysqlclient.18.dylib

    Note that everything is part of the command (Yes, the same directory is repeated twice). Adjust the command for your mysql version and libmysqlclient.<number here>.dylib.

    3) Created a new mysql user so that DBD::mysql could perform database tests. After I performed 1) and 2), the DBD::mysql install failed because tests couldn't be performed. Somewhere in the output it said to do this:

    mysql> grant all privileges on test.* to '7stud'@'localhost' identifie +d by 's3kr1t';

    On previous attempts to install DBD::mysql, I was told to do the same thing with root:

    mysql> grant all privileges on test.* to 'root'@'localhost' identified + by 's3kr1t';

    In any case, I started mysql:

    $ cd /usr/local/mysql $ sudo ./bin/mysqld_safe (ENTER YOUR PASSWORD, IF NECESSARY) (PRESS CONTROL-Z) $ bg (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL) To shutdown mysql (Don't do this yet!) $ cd /usr/local/mysql $ sudo mysqladmin shutdown

    Then I opened up a mysql shell:

    $ mysql -uroot -p password: <just hit return> .. .. ... mysql>

    And then I used the line from the DBD::mysql output:

    mysql> grant all privileges on test.* to '7stud'@'localhost' identifie +d by 's3kr1t';
    That created the mysql user 7stud with the password 's3kr1t' and granted 7stud privileges to use the 'test' database, which was created by mysql on installation. By creating the mysql user indicated in the output, you are letting DBD::mysql access mysql to perform tests.

    4) Installed DBD::mysql:

    $ cpan DBD::mysql

    EDIT: I mistakenly installed DBD::mysql into my perl-5.16.0t(compiled with threads) instead of my perl-5.16.0 which is where I wanted to install DBD::mysql. So I switched to 5.16.0:

    $ perlbrew use perl-5.16.0

    ...but once again I had installation problems:

    $ cpan DBD::mysql
    CPAN: Storable loaded ok (v2.34)
    Reading '/Users/7stud/.cpan/Metadata'
      Database was generated on Wed, 16 Jan 2013 19:07:11 GMT
    CPAN: YAML loaded ok (v0.84)
    Reading 51 yaml files from /Users/7stud/.cpan/build/
    CPAN: Time::HiRes loaded ok (v1.9725)
    ............................................................................DONE
    Restored the state of 1 (in 0.7206 secs)
    Running install for module 'DBD::mysql'
    Running make for C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz
    Prepending /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/arch /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/lib to PERL5LIB for 'get'
      Has already been unwrapped into directory /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe
    Prepending /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/arch /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/lib to PERL5LIB for 'make'
    CPAN: Parse::CPAN::Meta loaded ok (v1.4402)
    CPAN: CPAN::Meta loaded ok (v2.120630)
    CPAN: Module::CoreList loaded ok (v2.79)
      Has already been made
    Prepending /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/arch /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/lib to PERL5LIB for 'test'
    Running make test
      Has already been tested successfully
    Running make install
      Already tried without success
    $
    

    That's a pretty frustrating result since DBD::mysql was "tested successfully". I finally resorted to the nuclear option:

    $ cpan -f -i DBD::mysql

    In hindsight, I think I should have used even a bigger gun:

    $ perl -MCPAN -e shell cpan> fforce install DBD::mysql

    fforce makes cpan forget anything it has done before when trying to install a module and start the install from scratch. Here was the output:

    $ cpan -f -i DBD::mysql
    CPAN: Storable loaded ok (v2.34)
    Reading '/Users/7stud/.cpan/Metadata'
      Database was generated on Wed, 16 Jan 2013 19:07:11 GMT
    CPAN: YAML loaded ok (v0.84)
    Reading 51 yaml files from /Users/7stud/.cpan/build/
    CPAN: Time::HiRes loaded ok (v1.9725)
    ............................................................................DONE
    Restored the state of 1 (in 0.7274 secs)
    Running install for module 'DBD::mysql'
    Running make for C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz
    Prepending /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/arch /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/lib to PERL5LIB for 'get'
      Has already been unwrapped into directory /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe
    Prepending /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/arch /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/lib to PERL5LIB for 'make'
    CPAN: Parse::CPAN::Meta loaded ok (v1.4402)
    CPAN: CPAN::Meta loaded ok (v2.120630)
    CPAN: Module::CoreList loaded ok (v2.79)
      Has already been made
    Prepending /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/arch /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/lib to PERL5LIB for 'test'
    Running make test
      Has already been tested successfully
    Running make install
    Prepending /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/arch /Users/7stud/.cpan/build/DBD-mysql-4.022-LOppYe/blib/lib to PERL5LIB for 'install'
    Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/darwin-2level/auto/DBD/mysql/mysql.bs
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/darwin-2level/auto/DBD/mysql/mysql.bundle
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/darwin-2level/Bundle/DBD/mysql.pm
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/darwin-2level/DBD/mysql.pm
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/darwin-2level/DBD/mysql/GetInfo.pm
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/darwin-2level/DBD/mysql/INSTALL.pod
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/man/man3/Bundle::DBD::mysql.3
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/man/man3/DBD::mysql.3
    Installing /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/man/man3/DBD::mysql::INSTALL.3
    Appending installation info to /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0/darwin-2level/perllocal.pod
      CAPTTOFU/DBD-mysql-4.022.tar.gz
      /usr/bin/make install  -- OK
    

    5) I tested the DBI install with the following program (substitute in your own user, password, db, table, and column names):

    use strict; use warnings; use 5.012; use DBI; use DBD::mysql; # CONFIG VARIABLES my $db_type = "mysql"; my $database = "my_db"; my $host = "localhost"; my $port = "3306"; my $tablename = "people"; my $user = "root"; my $pw = ""; # DATA SOURCE NAME my $dsn = "dbi:$db_type:$database:$host:$port"; # PERL DBI CONNECT my $connect = DBI->connect($dsn, $user, $pw); # PREPARE THE QUERY my $query = "select * from $tablename"; my $query_handle = $connect->prepare($query); $query_handle->execute(); my($id, $name, $info); $query_handle->bind_columns(\$id, \$name, \$info); while($query_handle->fetch()) { say "$id, $name, $info"; }

    If you don't know how to create a mysql db, add a table, and insert some data, here are some commands to help you in that regard:

    mysql> CREATE DATABASE my_db CHARACTER SET utf8 mysql> show databases; mysql> use my_db; mysql> show tables; mysql> CREATE TABLE people (id INT(12) not null auto_increment primary + key, name VARCHAR(40), info VARCHAR(100)); mysql> describe people; #shows schema mysql> INSERT INTO people(name, info) VALUES("Sally, "abc") ; mysql> SELECT * FROM people; #Only use the following if you want to delete data: mysql> drop table people; mysql> drop database my_db;
Re: DBD::mysql won't install
by Anonymous Monk on Feb 28, 2014 at 21:09 UTC
    just make symlink at /usr/lib of /usr/local of sudo ln -s /usr/local/mysql-5.6.16-osx10.7-x86_64/lib/libmysqlclient.18.dylib

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (19)
As of 2014-04-23 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (551 votes), past polls