WWW database servers on Mac OS X 10.6.x, part I: Installing MySQL

By Grant Jacobs 16/03/2011

PROGRAMMING/BIOINFORMATICS: Part I of a outline guide to setting a Mac OS X machine up for a web server database using Mac OS X 10.6.x, MySQL and Perl.

Originally intended as one long document, I have broken this into several parts to better suit my time. Part I focuses on installing the relational database, MySQL. (I may offer these instructions as a complete document once the series is complete.) These instructions do not consider Mac OS X Server, which has a slightly different setup for MySQL.


I’m also not going to get into the details of tweaking config files and whatnot – the aim here is to offer a basic recipe that should work for most people without too much extraneous fluff which confuse a first-time installs. It’s a prescriptive outline rather than an detailed explanation.

While this description is oriented at those intending to use the Perl programming language to interact with a relational database, with a WWW interface for users, this first part only deals with MySQL itself. I’m going to assume installing it on a client’s machine, i.e. you’ve no idea what it’s set up with.

Firstly, make sure that the machine has Apple’s Developer Tools installed. A typical bought-from-the-store machine will not have Developer Tools installed. The simplest way to check if this has been done is to see if the /Developer directory is present.


Usually this is provided an ‘extra’ installation that comes with the installation disk (DVD). It’s not installed in default installations of computers bought from a store.

Bring the Developer Tools up to date while you’re at it, as the DVD version may not be the current version.

The installer for Developer Tools can take some time so you might as well get a coffee on or do some other job while it does it’s thing.

Next, check the version of Perl on the system.


There are two versions[1] of Perl for Mac OS X: a 32-bit version and a 64-bit version. The 32-bit version can only communicate with a 32-bit MySQL. Likewise, the 64-bit Perl can only communicate with a 64-bit MySQL.

The default Perl within Mac OS X was changed from 32-bit to 64-bit with Mac OS X 10.6.x.

Rather than rely on the operating system version, you can check for yourself. To check the version, open Terminal and enter:

perl -V

You’ll get a fairly complex output, but what you’re looking for is ‘x86_64’ or ‘x86_32’ indicating which of 32-bit or 64-bit CPUs are targeted. You might as well use grep to make this easier:

perl -V | grep x86_64

If you get no output, try

perl -V | grep x86_32

Download the appropriate version of MySQL.

(I’m going to overlook MySQL WorkBench or other GUI database construction applications. I can recommend Navicat Lite for MySQL as another product to look at to see if it suits your needs.)

Before trying to install MySQL, make sure that any existing installations of MySQL are shut down. I’m going to continue on the assumption that this has been done. (This is meant as a simple recipe for installing onto a machine from fresh, not an upgrade.[2]) The ReadMe.txt file on the MySQL disk image has instructions for shutting down running MySQL databases. (Basically, use ‘mysqladmin shutdown’ in Terminal.)


On the disk image for MySQL you should see two packages and one preference panel (shown above), listed in the order I suggest you tackle them:





If you want MySQL to start automatically during system startup, you also need to install the MySQL Startup Item. It is part of the Mac OS X installation disk images as a separate installation package. Simply double-click the `MySQLStartupItem.pkg’ icon and follow the instructions to install it. The Startup Item need be installed only once. There is no need to install it each time you upgrade the MySQL package later.

You should find that the database software has been be installed into /usr/local/mysql/

Likewise, the Startup Item for MySQL should have been installed into /Library/StartupItems/MySQLCOM

To install the Preference Pane, drag it into /Library/PreferencePanes or /Users/UserName/Library/PreferencePanes as suits.


Opening System Preferences, you should now see a MySQL PreferencePane at the lower-left (shown to left).

Start up MySQL by pressing ‘Start MySQL Server’. If you want the database server to start up on restarting or booting the system, select ‘Automatically Start MySQL Server on Startup’. (Goodness knows why Apple has capitalised ‘start’ or ‘startup’; it’s supposed to be a sentence, not a title.)


Leave the database running for the rest of the installation.

In the next part we’ll look at installing the Perl modules to interact with the database and creating the initial (empty) database.


[1] A wee fib. In fact there are three versions, 5.10.x in 64- and 32-bit and 5.8.9 in 32-bit, but I’ll consider that most people aren’t interested in the older of the two 32-bit versions. There is an argument by some to use the 32-bit Perl on the grounds that some (more obscure) Perl modules might not work well under 64-bit.

[2] My thinking is that most people updating an installation will have been through it before and so wouldn’t be needing or reading this document.

Some other articles from Code for Life:

GoPubMed — PubMed browsing using ontologies

LyX for free word-processing

Backups, part I

Time Machine backups — some ‘gotchas’

Sinclair ZX envy

0 Responses to “WWW database servers on Mac OS X 10.6.x, part I: Installing MySQL”