For 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 is again as simple as installing any application you come across. You download the disk image, double click on the install package and your done. There are some additional steps you need to take to get everything working properly but you don’t need to recompile it as we used to.
First you need to get yourself the disk-image. You can find it by going to the Mysql.com download section and find the “Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive” or “Mac OS X ver. 10.6 (x86, 32-bit), DMG Archive” depending on your Macs capability.
When the disk image is finished downloading it will be mounted automatically and you can open the contents. Double click on the package installer to start the installation. Follow the instructions and you will have it installed when finished.
The Mac OS X package of MySQL installs itself into ‘
/usr/local/mysql-5.5.xx-osx10.6-x86_xx‘ 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 ‘
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 do not install this as it uses an outdated manner of starting the database after a reboot. The same is true for the MySQLStartupitem, please don’t use it. We’ve got a better method of starting MySQL automatically.
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:
and restart the Terminal to test it.
To make sure that all the programs compile correct you’ll need to execute the following command, when you’ve finished the installation, in the Terminal:
sudo install_name_tool -id /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.dylib
There is another little snag, Mac OS X has a funny way of using _username for user running daemon processes. The “mysqld_safe” script which is used to start mysqld safely will use the user “mysql” while the user “_mysql”has been given access to the /data directory. You can see that this will result in a conflict. Therefore we need to edit the “mysqld_safe” script and add a single character, change: