Archive for January, 2006

Adding Perl support for MySQL on Mac OS X part 3

Friday, January 13th, 2006

Now we have MySQL up and running, it’s time for the Perl support. Mac OS X comes with a standard Perl port, without the MySQL support. It is not advisable to add modules to the this built-in port of Perl, it is possible a Mac OS X software update from Apple could temper with the additions. Instead, we will install a completely separate port of Perl, and to this port we will add the MySQL support. First, go to the ActivePerl download page, follow the ‘Download ActivePerl’ link, fill in or skip the form, and download the ‘Mac OS X’ version. Mount the downloaded image, and double-click the installer. This will install the ActivePerl port in the /usr/local directory on your harddisk.

Open a terminal window (I prefer to use iTerm), and type:

cd /usr/local

Give yourself a root-password (choose a good one!):

sudo passwd root

And become root:


Now, type (with your version number of ActivePerl) to create a convenient path to the new Perl:

ln -s ActivePerl-5.8 perl

The new Perl is now available as /usr/local/perl/bin/perl, if you want to use it your file with Perl commands should start with:


Adding MySQL support for this Perl

This new Perl has now been installed, but it is still without the support for MySQL! So finally we will come to the last step in this process. Type in the terminal window:

cd perl/bin

You should now be in the directory with the binaries of ActivePerl. Type:


This will start a nifty utility which will add modules to the ActivePerl port. Type:

install DBI

This should download and install the DBI module. Then type:

install DBD-mysql

This should download and install the DBD-mysql module. Finish with a simple q, and the ‘ppm’ program should quit.

This is it! We now have Perl installed with MySQL support!

Adding Perl support for MySQL on Mac OS X part 2

Friday, January 13th, 2006

I’ve been working on it, and it seems it is not as difficult as it was last year! We’ll start with the easy bits:

Download and install MySQL

This is fairly easy, go to the MySQL website, and follow the link ‘downloads’. Choose the ‘Generally Available (GA) release (recommended)’ version (at the moment this is MySQL 5.0), and follow that link. On the next page, scroll down untill you reach the section with ‘Mac OS X downloads’, and download the version that is suitable for your system and OS.

After the download is complete, doubleclick both packages and follow the instructions on the screen. You can also doubleclick ‘MySQL.prefpane’, which will install a small pane in your System Preferences, but this is less useful if you install ‘MySQL Administrator’; this pane can only stop and start the MySQL server, and force it to start when your Mac boots.

Download and install PHP

PHP you ask? Well yes, sometimes it can be handy to have PHP installed also, so we will do just that! Go to the official PHP website, again follow the link ‘downloads’. Under ‘Binaries for other systems’ (on the left), you will find Mac OS X. Follow that link, and search on this page for the heading ‘PHP 5 on Mac OS X 10.3/10.4′ (or later versions of Mac OS X when thay are available). Mac OS X Panther and Tiger come with Apache 1.3, so you need ‘PHP 5.0.4 for Apache 1.3′ (or higher if available); click on it and download the package. Again, mount the downloaded diskimage, doubleclick the package and follow the instructions on the screen. PHP is now available in Apache.

Download and install MySQL utilities

A handy utility that gives a lot of information about the MySQL server and databases is MySQL Administrator. On this page, follow the ‘Download Binaries & Source’ link (on the right side of the page), choose the version suitable for your system, and then choose the Mac OS X version.

Another utility that I found very convenient was CocoaMySQL, nice interface, and handy to inspect the contents of the databases, but it didn’t work quite as it should when I installed it under Tiger, but you can try it anyway.

Adding Perl support for MySQL on Mac OS X part 1

Thursday, January 12th, 2006

Mac OS X comes standard with Perl, but, unfortunately, the modules necessary to access a MySQL database are not included in this Perl implementation. You have to add them yourself, and this is not a self-evident process. Why use Perl when there is PHP you may ask? PHP comes with MySQL support built in! Well, I’m very used to Perl, and don’t want to learn more PHP than is absolutely necessary. Although I must admit that this is not a very sensible attitude, commercial hosting companies usually don’t offer Perl support for MySQL either so I couldn’t use my knowledge on a real webserver. I will have to put my own webserver online somewhere!