MySQL logoFor most of the systems/applications we are going to install a database is required to store the information that is used by the applications. All the users and their mailbox configurations, the spamfilter settings and learned filters, the pages in my WordPress blog, the discussions in the forum, etc…

I’ve choosen for the MySQL Community Server as the database of choice as it was the first choice of most of the systems/applications I installed on my server. Other Choices are available but aren’t as widely supported by applications I use.

Installing MySQL on Mac OS X used to be as simple as installing any application you came across before. You download the disk image, double click on the install package and your done. However the current binary install package from MySQL.com has a problem, it’s compiled with static libraries and we need shared libraries to use MySQL in other self-compiled applications. Therefore the added complication in installing this application is that after the using the binary installation we need to compile and install MySQL again. Another reason is that the Community server releases are not always available as binary release but always as a source release.

First you need to get yourself the disk-image. You can find it by going to the Mysql.com download section and find the link for the current release. Please use version 5.1.x as this is the official current production release. You will get a long list of all kinds of packages for a lot of different platforms. Find the first section mentioning Mac OS X downloads and download the Standard version. Filename should be mysql-standard-5.1.xx-osx10.4-powerpc.dmg for a PowerPC mac or mysql-standard-5.1.xx-osx10.4-i686.dmg for an Intel based Mac.

When the disk image is finished downloading it will be mounted automatically and you can open the contents. Double click on the mysql-standard-5.1.xx-osx10.4-powerpc.pkg (if you have a PowerPC based Mac) to start the installation or the other for an Intel based Mac. Follow the instructions and you will have it installed when finished.

The Mac OS X package of MySQL installs itself into ‘/usr/local/mysql-standard-5.1.xx-osx10.4-powerpc‘ and also installs a symbolic link, ‘/usr/local/mysql‘, pointing to the new location. If a directory named ‘/usr/local/mysql‘ exists, it is renamed to ‘/usr/local/mysql.bak‘ first. Additionally, the installer creates the grant tables in the ‘mysql’ database by executing ‘mysql_install_db‘ after the installation. The MySQL socket file is created as ‘/tmp/mysql.sock'.

The installer also comes with a Preference Pane which you can install by just double clicking on the MySQL.prefpane icon. With the Preference Pane you can start and stop the MySQL server and select if you want to startup at boot time. Please note that this will only change the entry in the ‘/etc/hostconfig‘ file as described above. This will not (de-)install the Startup Item for MySQL.

MySQL Preference Pane

To be able to use the MySQL commands like mysql, mysqldump and mysqladmin from the Terminal you need to add the path to the binaries to your PATH environment variable. You can do that by creating or editing the file ‘.bash_profile’ in your home directory (don’t forget the dot in front of the filename). Add the line:
export PATH="$PATH:/usr/local/mysql/bin"
and restart the Terminal to test it.

If you are going to try to compile PHP and install the mailserver, please continue the installation process on the page that is correct for your setup: