DBD::mysql, MySQL and OS X Lion

I downloaded and installed MySQL Community Server 5.5.15 from http://dev.mysql.com/downloads/mysql/5.5.html

Using CPAN, I then tried to install DBD::mysql on a fresh install of OS X Lion and was presented with an error saying it was unable to load the library.

#     Error:  Can’t load ‘/private/var/root/.cpan/build/DBD-mysql-4.019-H1RD6j/blib/arch/auto/DBD/mysql/mysql.bundle’ for module DBD::mysql: dlopen(/private/var/root/.cpan/build/DBD-mysql-4.019-H1RD6j/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.18.dylib
#   Referenced from: /private/var/root/.cpan/build/DBD-mysql-4.019-H1RD6j/blib/arch/auto/DBD/mysql/mysql.bundle

After a bit of searching, I came across http://probably.co.uk/problems-installing-dbdmysql-on-os-x-snow-leopard.html which although it’s for Snow Leopard has a very similar error and the fix works great on Lion as well.

$ sudo install_name_tool -id /usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib /usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib

$ otool -D `mdfind libmysqlclient.18.dylib`
/usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib:
/usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib

After running the name_install command, DBD::mysql built and tested correctly.

One comment on “DBD::mysql, MySQL and OS X Lion”

  • Adam Stoller says:

    (I’m still searching the web – but as I saw your posting here…)

    I have mysql-5.5.14-osx10.6-x86 (although interestingly enough, when I run mysql and do ‘? version’ it comes back with 5.5.16-standard), which I’ve gotten that up and running on Lion and have been using it without any significant problems.

    So I went to my Perl installation (it had been 5.8.3 but I was running into all sorts of issues with it, so I downloaded fresh source and built it myself – version 5.14.1) and tried to do a ‘cpan’ installation of DBD::mysql (after having done an installation of DBI) – and it kept failing, so I went to the actual build directory. ‘make’ seems to be fine, but it dies when trying to do a ‘make test’:

    (Macintosh-3) DBD-mysql-4.019-GhjJw_ > sudo make test
    PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
    t/00base.t .................. 1/6 Bailout called. Further testing stopped: Unable to load DBD::mysql

    # Failed test 'use DBD::mysql;'
    # at t/00base.t line 21.
    # Tried to use 'DBD::mysql'.
    # Error: Can't find 'boot_DBD__mysql' symbol in /Users/ghoti/.cpan/build/DBD-mysql-4.019-GhjJw_/blib/arch/auto/DBD/mysql/mysql.bundle
    # at (eval 7) line 2
    # Compilation failed in require at (eval 7) line 2.
    # BEGIN failed--compilation aborted at (eval 7) line 2.
    FAILED--Further testing stopped: Unable to load DBD::mysql
    make: *** [test_dynamic] Error 255
    (Macintosh-3) DBD-mysql-4.019-GhjJw_ > find blib/lib -name "*.pm"
    blib/lib/Bundle/DBD/mysql.pm
    blib/lib/DBD/mysql/GetInfo.pm
    blib/lib/DBD/mysql.pm
    I tried the steps you mentioned with install_name_tool and otool, and though they seemed to work (no errors shown) – they didn’t seem to resolve the issue I’m having.

    Any ideas?

Comments are closed.