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 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.

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:
- Compiling MySQL on Tiger
- Compiling MySQL 5.0.x in 32 bits mode on Leopard
- Compiling MySQL 5.0.x in 64 bits mode on Leopard
- Compiling MySQL 5.1.x in 32 bits mode on Leopard
- Compiling MySQL 5.1.x in 64 bits mode on Leopard
- Compiling MySQL 5.1.x in 32 bits mode on Snow Leopard
- Compiling MySQL 5.1.x in 64 bits mode on Snow Leopard



1:30 am
Thanks for a great documentation.
Just wanted to let you know that I just installed MySQL 5.1.33 on Leopard 10.5.6 and the Preference pane works.
Cheers
11:54 pm
Hi,
I’d like to know how do we add the PATH Environment? I don’t manage to get the .bash_profile. Can I know which home directory that you’re mentioning? Thanks.
12:40 am
How do we test it in the terminal?
Sorry, I’m terminal newbie. Thanks.
6:07 am
@Nicv, if you open a Terminal session you are in your users home directory. If you don’t know what you doing please stop as these instructions might be to advanced for you. If you are ready to learn and make mistakes the command to edit your profile is:
`vi .bash_profile`
Please google for instructions on how to use vi.
6:16 am
Hi Richard,
I’m ready to learn and try. I’ve created a .bash_profile, cause I didn’t see any old file name .bash_profile with the export PATH=”$PATH:/usr/local/mysql/bin” as content.
So, how to execute this? Many Thanks
6:19 am
@Nicv, just open a new Terminal session. If you type in `mysql` followed by enter you should get a proper answer instead of command not found.
2:54 am
It seems when I upgraded to 10.5.7 from 10.4.1, MySQL, PHP and Apache was not working properly. I was able to get php to run and Apache buy MySQL was not connecting properly. I wanted to start fresh and reinstall everything so I uninstalled MySQL using these instructions:
To uninstall MySQL and completely remove it from you Mac do the following:
* sudo rm /usr/local/mysql
* sudo rm -rf /usr/local/mysql*
* sudo rm -rf /Library/StartupItems/MySQLCOM
* sudo rm -rf /Library/PreferencePanes/My*
* edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
* sudo rm -rf /Library/Receipts/mysql*
* sudo rm -rf /Library/Receipts/MySQL*
Then I reinstalled 5.1 version and it seemed to all go in correctly however I see no local file in usr. My localhost is in my webserver file yet there is no StartupItems there either. I just want to start all over again and make sure there is a fresh install of MySQL in my system.
system:
MacBookpro 17 inch
2.33 ghz
2 gb -ddr2 SDram 667 mhz intel core 2 duo
Thanks for any help on this
12:02 pm
@Will, you can just install a new version of MySQL without any problem. The newer version will just overwrite the older one. You can check by running mysql_config, which will show you the actual version you are using plus configuration.
10:08 pm
I am using OS X 10.5.7 and have not gotten the setting of the path to mysql to work. I think that in Leopard, .bash_profile is no longer used, but is replaced by .profile. In either case, after creating the file, and restarting terminal, I get mysql: command not found. Typically I just use cd to migrate to the /mysql/bin directory, but it is a pain, and I’d like to learn how to do this. I’ve Googled for a while, but none of the suggestions have worked. Also when I echo $PATH, I do not get the path that is in the .bash_profile or .profile files. I suspect that I should be altering the path.d file, but is that a good thing?
Any help appreciated.
8:22 am
David, in Leopard .bash_profile is still used. I think you made a typo in your profile.
2:06 am
You need to look in the archives for powerpc versions of mysql as of 2010. From the bottom of this post…
http://forums.mysql.com/read.php?117,297852,299814#msg-299814
You *can* find MySQL 5.1.40 packages for Mac OS X and PowerPC on the (not that easy to find I have to admit) page
http://downloads.mysql.com/archives.php?p=mysql-5.1&v=5.1.40