Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just got a new Mac and have been trying to setup a local development environment for my perl applications for a few days now with no luck. I'm getting no where fast so I hope someone else who has done this successfully could help.

I started by installing MAMP which I thought would take care of everything for me but unfortunately it doesn't take care of some important perl modules. I used CPAN to install all our required modules except that it seems DBD::mysql doesn't install correctly through CPAN. After reading a lot online, lots of people reported problems with this and recommended using MacPorts to install the module which I have tried doing with no luck using the following command:

sudo port install p5-dbd-mysql

After what seems like a successful install of DBD::mysql, Apache continues to report the following error when trying to run any of our Perl scripts:

[Fri Apr 30 18:51:07 2010] [error] [client] install_driver(mysql) failed: Can't locate DBD/ in @INC (@INC contains: /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at (eval 1835) line 3.
[Fri Apr 30 18:51:07 2010] [error] [client] Perhaps the DBD::mysql perl module hasn't been fully installed,
[Fri Apr 30 18:51:07 2010] [error] [client] or perhaps the capitalisation of 'mysql' isn't right.
[Fri Apr 30 18:51:07 2010] [error] [client] Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.

I'm not sure where to go from here but my Mac isn't much of a development environment if Perl isn't able to talk to the database. I'd really appreciate any help and advice you might be able to provide in getting my system setup successfully. Thanks in advance!

share|improve this question
With Macports did you install mysql before installing p5-dbd-mysql? – tegbains May 4 '10 at 6:43

I've spent near 4 days fighting with this issue and here's the setup that finally got me there:

  • don't use macports
  • use the stock perl, with a twist:
    • Snow Leopard ships with 2 perls: 5.10.0 and 5.8.9 - switch to the earlier version like so:


% defaults write Prefer-32-Bit -bool yes

% defaults write Version 5.8.9

  • download the 32bit version of mysql from ("Mac OS X ver. 10.6 (x86, 32-bit)")
    • Find the instructions on Google - I just put the extracted directory in /usr/local and linked /usr/local/mysql to that directory
  • CPAN seems to prefer the 5.10.0-specific install locations, so I downloaded DBD::mysql from and did the usual install:

% perl Makefile.PL

% make

% sudo make install


  • In order to get CPAN to get its config from the right perl version, and to get Apache to run perl CGIs with the right perl version, use the following command instead of the last one in the above list:

% defaults write /Library/Preferences/ Version 5.8.9

You'll have to be an admin to do this. After this, HUP apache and you'll be all set.

share|improve this answer

I've gone through the same headaches that Steve Ivy did, with the same solution.

In addition, because I'm using mod_perl2, I also had to build mod_perl manually -- if you download it from CPAN, then issue:

    $ cd ~/.cpan/build/mod_perl-2.*

    $ export ARCHFLAGS="-arch i386 -arch x86_64"
    $ export CFLAGS="-arch i386 -arch x86_64"

    $ perl Makefile.PL
            # (will prompt for where apxs is:

    $ make -j8
            # make test will fail ... had to modify a file:

    $ vi t/response/TestAPI/
            # around line 117, comment out the line:

            AuthGroupFile @DocumentRoot@/api/auth-groups

            # (I have no idea *why* this is failing, though)

    $ make test
            # in my case, it failed a couple of tests ... 5 out of 238
            # most were because we're running older versions of
            # modules, or the pure-perl varient (you'll see 'PP' in
            # the module name, or it complains about (something)XS)

            # If you're concerned, see t/logs/error_log

    $ sudo make install

... and then force Apache2 down to 32 bit, by following Michael Cramer's advice

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.