Phil Gyford


Monday 7 June 2004

PreviousIndexNext Installing DBI and DBD::mysql on Mac OS X Panther

A more technical entry than I’d usually post here, but this is for the benefit of anyone who is having problems installing DBI and DBD::mysql on Mac OS X. I needed it to get Movable Type using MySQL on my PowerBook and spent far too long trying to get this to work. I should, however, say that I really don’t understand what any of this is or does, only that it makes Movable Type’s mt-check.cgi script tell me DBD::mysql is installed. Whatever that is. Follow these instructions at your own risk!

My problem was that having found these simple instructions for installing DBD::mysql, I’d always get this error when following step 4:

Checking if your kit is complete...
Looks good
Warning: prerequisite DBI 1.08 not found.

This discussion implied I might need to install the Apple Developer Tools. Doing this made no difference.

Installing Bundle-DBI.dmg from this page made no difference.

Thankfully Nick came to my rescue and told me how to make and install the required perl modue, a process I’ve simply never succeeded with over the years. So the full sequence is now:

  1. Download DBI from cpan (click the tiny easy-to-miss ‘Download’ link).
  2. Unpack the file using Stuffit Expander.
  3. Using Terminal, cd into the directory you just created (eg, type cd DBI-1.42)
  4. Type perl Makefile.PL
  5. Type make && make install
  6. Follow the instructions mentioned above for installing DBD::mysql.

Hopefully then you’ll be up and running. Unfortunately, if you have any problems I’m unlikely to be of assistance, as I barely understand what’s going on myself.


Does the 'cpan' command not work on Panther? Typing:

cpan Bundle::DBI

should do the works for you.

Posted by Yoz on 7 June 2004, 2:43 pm | Link

Last time I tried CPAN on my Mac (before Panther I think), it started trying to update the whole of Perl or something. I have thus been put off for life. And although I've also, previously, been put off installing any perl modules by my repeated lack of success, I tried Nick's more manual instructions before his second suggestion of cpan... thankfully it worked.

Posted by Phil Gyford on 7 June 2004, 3:03 pm | Link

If you're serious about developing with Perl, install the developer tools. If you don't, things will not work. Always install the developer tools. Really. Not kidding here.

CPAN is much much happier on Panther than it was on Jaguar, where it did have that annoying tendency to go batshit and try to install the whole of Perl 5.8 over 5.6. Learn to love it, and if you can't, learn to love CPANPLUS instead. They really do save you more trouble than you care to think about. (Imagine if DBI relied on a module, and then imagine that module relied on another one.)

It might also be worth noting that some build failures with DBD::MySQL are related to a bug in (pre-release) version of Perl shipped with Panther. I'm not sure if this has been fixed in any of the subsequent point releases, but the instructions for doing it yourself are here:

Posted by Paul Mison on 7 June 2004, 9:50 pm | Link

Thanks Paul. I think though that any thoughts I may once have had about doing serious Perl development have waned... too much PHP has made Perl seem impossibly difficult and I need Perl rarely enough that the rustiness will probably never disappear. I really just wanted Movable Type to work with MySQL...

Posted by Phil Gyford on 8 June 2004, 9:58 am | Link

There instruction worked after I downloaded the most current version of Xtools, older versions of the developer package may not work for MACOSX 10.3.4 install perl DBI DBD

Posted by Justin Paschall on 28 July 2004, 1:22 pm | Link

Manual install on 10.2.8 with Perl 5.6.0 went well.

I had to install Test::Simple 0.49 from CRAN to get rid of Test/ deficiency. From there simply followed above directions, with the exception of NOT ammending the Makefile created by Makefile.PL when installing DBD::mysql - apparently fixed (didn't find the offending line in the Makefile...)


Posted by Jeff on 1 November 2004, 3:12 am | Link

A couple of comments. Step 5 should be split into 3 steps.

5. make - to make the libraries, etc.
6. make test - to test the library and mysql, optional
7. sudo make install - the installation will most likely require admin privileges since it will try to install a couple of applications into /urs/bin which it doesn't have the rights to. Not using sudo can cause problems in the long run if other applications relying on DBI think those applications are present.

- Jonas

Posted by Jonas Rabbe on 1 December 2004, 5:28 pm | Link

Phil, thanks very much for this article. I am in pretty much the same boat you were in. Am running Mac OS X Server 10.3.7 on a PowerBook G4/500 and want to get DBD::mysql installed for my Movable Type blog (want to convert from BerkeleyDB to MySQL). Am running Perl 5.8.1 (I think part of the standard Panther Server installation).

I am stuck on the 'perl Makefile.PL' step, however:

$ perl Makefile.PL

*** You are using a perl configured with threading enabled.
*** You should be aware that using multiple threads is
*** not recommended for production environments.

*** Note:
The optional PlRPC-modules (RPC::PlServer etc) are not installed.
If you want to use the DBD::Proxy driver and DBI::ProxyServer
modules, then you'll need to install the RPC::PlServer, RPC::PlClient,
Storable and Net::Daemon modules. The CPAN Bundle::DBI may help you.
You can install them any time after installing the DBI.
You do *not* need these modules for typical DBI usage.

Optional modules are available from any CPAN mirror, in particular…

Creating DBI::PurePerl test variant: t/zvpp_01basics.t
Creating DBI::PurePerl test variant: t/zvpp_02dbidrv.t
Creating DBI::PurePerl test variant: t/zvpp_03handle.t
Creating DBI::PurePerl test variant: t/zvpp_04mods.t
Creating DBI::PurePerl test variant: t/zvpp_05thrclone.t (use threads)
Creating DBI::PurePerl test variant: t/zvpp_06attrs.t
Creating DBI::PurePerl test variant: t/zvpp_07kids.t
Creating DBI::PurePerl test variant: t/zvpp_08keeperr.t
Creating DBI::PurePerl test variant: t/zvpp_09trace.t
Creating DBI::PurePerl test variant: t/zvpp_10examp.t
Creating DBI::PurePerl test variant: t/zvpp_14utf8.t
Creating DBI::PurePerl test variant: t/zvpp_15array.t
Creating DBI::PurePerl test variant: t/zvpp_20meta.t
Creating DBI::PurePerl test variant: t/zvpp_30subclass.t
Creating DBI::PurePerl test variant: t/zvpp_40profile.t
Creating DBI::PurePerl test variant: t/zvpp_41prof_dump.t
Creating DBI::PurePerl test variant: t/zvpp_42prof_data.t
Creating DBI::PurePerl test variant: t/zvpp_50dbm.t
Creating DBI::PurePerl test variant: t/zvpp_60preparse.t
Creating DBI::PurePerl test variant: t/zvpp_80proxy.t
Checking if your kit is complete...
Looks good

Error: Unable to locate installed Perl libraries or Perl source code.

It is recommended that you install perl in a standard location before
building extensions. Some precompiled versions of perl do not contain
these header files, so you cannot build extensions. In such a case,
please build and install your perl from a fresh perl distribution. It
usually solves this kind of problem.

(You get this message, because MakeMaker could not find "/System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h")
# Looks like your test died before it could output anything.

Any suggestions?


Posted by Derek Tom on 14 January 2005, 4:10 pm | Link

I'm afraid I know next to nothing about this kind of stuff Derek. FWIW, I have had more luck recently installing stuff using cpan than last time I tried (a couple of years previously). Sorry I can't be more help.

Posted by Phil Gyford on 14 January 2005, 4:23 pm | Link

Ha!... Not true!... Your article has already been helpful and insightful for me. Thanks for your feedback. Not sure what cpan is but will check it out. I would guess that it is similar to fink. Actually, my problem might be due the fact that I did not install the developer tools so I am going to try that... this was suggested by Seth on his blog here: Will see...

Thanks again!


Posted by Derek Tom on 15 January 2005, 12:24 pm | Link

One big thing on installing Perl Modules on OS X 10.3: Be sure that you install the Developers Tools from the disk included with 10.3. The version of Perl included with 10.3 is incomplete until you install the Developers Tools and the Makefile.PL won't run completely.

Posted by Bodhi Cat on 4 January 2006, 6:08 pm | Link

These instructions are as valid today as ever. I used this to install these modules on my iNtel iMac with 10.4.5. [I did not think I would need to install DevTools from the DVD. I was wrong.]

Posted by Chris on 26 February 2006, 3:57 am | Link

Hi Guys,

I have just recieved delivery of a shiney new intel mac book pro, coming from a linux/gentoo/solari background I thought i would try something i didnt have to compile and build for 5 days to get it working,

I am having issues compiling the DBD::Mysql module which i have downloaded from CAPN.

I have already installed the DBI::Bundle which looked ok on install, here is the ourput i am getting.

clarke-wardles-computer-2:~/Desktop/DBD-mysql-4.001 wardlec$ perl Makefile.PL
I will use the following settings for compiling and testing:

cflags (mysql_config) = -I/usr/local/mysql-standard-5.0.27-osx10.4-i686/include -Os -arch i386 -fno-common
embedded (mysql_config) =
libs (mysql_config) = -L/usr/local/mysql-standard-5.0.27-osx10.4-i686/lib -lmysqlclient -lz -lm
mysql_config (guessed ) = mysql_config
nocatchstderr (default ) = 0
nofoundrows (default ) = 0
ssl (guessed ) = 0
testdb (default ) = test
testhost (default ) =
testpassword (default ) =
testsocket (default ) =
testuser (default ) =

To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.

Checking if your kit is complete...
Looks good
Using DBI 1.53 (for perl 5.008006 on darwin-thread-multi-2level) installed in /Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBI/
Writing Makefile for DBD::mysql
clarke-wardles-computer-2:~/Desktop/DBD-mysql-4.001 wardlec$ make
cp lib/DBD/ blib/lib/DBD/
cp lib/DBD/mysql/ blib/lib/DBD/mysql/
cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod
cp lib/Bundle/DBD/ blib/lib/Bundle/DBD/
cc -c -I/Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBI -I/usr/local/mysql-standard-5.0.27-osx10.4-i686/include -Os -arch i386 -fno-common -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -O3 -DVERSION=\"4.001\" -DXS_VERSION=\"4.001\" "-I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE" dbdimp.c
dbdimp.c: In function 'mysql_dr_connect':
dbdimp.c:1677: error: 'ulong' undeclared (first use in this function)
dbdimp.c:1677: error: (Each undeclared identifier is reported only once
dbdimp.c:1677: error: for each function it appears in.)
dbdimp.c:1677: error: parse error before numeric constant
make: *** [dbdimp.o] Error 1

Any help would be appreciated.

Thanks Clarke (Virgin Mac user)

Posted by Clarke Wardle on 9 February 2007, 12:18 pm | Link


You need to add a line to /usr/local/mysql/include/mysql_com.h . Stick the following at the top of the file:

typedef unsigned long ulong;

I found this tip over at…

Once I did that, I got through that error, but I had problems at the linking stage. If you're using a G5, and 64-bit MySQL 5.0 (perhaps other 64-bit versions as well), you will likely get an error like:

/usr/bin/ld: truncated or malformed archive: /usr/local/mysql/lib/libmysqlclient.a (ranlib structures in table of contents extends past the end of the table of contents, can't load from it)

After I reinstalled MySQL 32-bit (using the binaries from, the DBD::mysql package compiled and installed without a problem (in fact, I didn't even have to add that line to mysql_com.h).

Hope this helps...


Posted by Phil Christensen on 3 June 2007, 5:55 pm | Link

Commenting is disabled on posts once they’re 30 days old.

Some sites linking to this entry (Trackbacks)

I have not had a test copy of my blog since I got the new iNtel iMac. Part of the reason was I did not have everything setup. Namely those parts of Perl that MT required to do its thing to mySQL. The problem was that I did not remember...
At ', how did I get here?...' on Sunday 26 February 2006, 3:53 AM