Can't install Perl DBI or DBD::mysql after Mountain Lion upgrade

I recently upgraded to Mountain Lion and found that my Perl DBI scripts stopped working, with the error message "Can't locate DBD/mysql.pm in @INC".


The last time this happened, after upgrading to Lion, the solution was to install the new version of Xcode. Then I was able to use the Perl CPAN module to install DBI and DBD::mysql. (MySQL is already installed and running with no problem on the Mountain Lion machine.)


Now I have installed Xcode 4.5.1, and tried


mrb% sudo perl -MCPAN -e shell


[then CPAN configures itself]


cpan[1]> install DBI


and it fails with this final message:


/System/Library/Perl/5.12/darwin-thread-multi-2level/CORE/perl.h:583:11: fatal error:

'sys/types.h' file not found

# include <sys/types.h>

^

1 error generated.

make: *** [Perl.o] Error 1

TIMB/DBI-1.622.tar.gz

/Developer/usr/bin/make -- NOT OK

'YAML' not installed, will not store persistent state

Running make test

Can't test without successful make

Running make install

Make had returned bad status, install seems impossible

Failed during this command:

TIMB/DBI-1.622.tar.gz : make NO



Can anybody help?

Posted on Oct 11, 2012 8:49 AM

Reply
6 replies

Oct 11, 2012 9:34 AM in response to Michael Boudreau

Here is a link to a resolution in Lion. It may also solve your Mountain Lion Perl DBD issue as well.


If you run the command below before executing your Perl script the library is found and all is well!

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"


Put this in your .bashrc or .bash_profile.


On Apple StackExchange, Matthew Weiss had another approach.


I found on another website the following command

$ sudo perl -MCPAN -e 'CPAN::Shell->notest(install => CPAN::Shell->r)'

This updated all my perl modules and all is back to normal. Not sure why or what, but don't care that it is working now.

Oct 12, 2012 10:12 AM in response to Michael Boudreau

Michael Boudreau wrote:


I'm not using the bash shell, so the export command doesn't work:


mrb% export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

DYLD_LIBRARY_PATH: Undefined variable.


I'm reluctant to run the command Matthew Weiss tried without knowing exactly what it's going to do.

Your reluctance to run the previously supplied Perl command is reasonable. Looks scarier than any solution.


Search or pose your question on stackoverflow, superuser, stackexchange, or Perl specific forums.


Good luck.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Can't install Perl DBI or DBD::mysql after Mountain Lion upgrade

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.