Richard
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



Comments
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
4:12 am
Since the directions were originally written a while back, I was wondering: is it still a problem w/ the MySQL installation that it uses static libraries? Didn’t know if maybe that’d been remedied on newer distributions… Thx, Fred
4:16 am
Sorry for the double-post: Also…there are now versions in the Archive section of MySQL downloads for 5.4, 5.5, and 6.0. Do we still need to stick to 5.1? Thx!
5:33 am
@Fred, no problem. Yes you still need to compile to get the proper libraries, sorry.
5.1 is currently the latest GA version, the others are only for development and are not considered stable enough for production.
11:09 am
Do I need the binary? If I install only from source, will the only thing lacking be the preferences pane?
2:46 pm
No you don’t need to install the binary. But if you don’t you need to do a lot of manual steps which will be done automatically when you install the binary. Some of it is described here: http://dev.mysql.com/doc/refman/5.1/en/post-installation.html
2:34 am
Hi, I am considering setting up a server on a C2D Mac mini running SL as described on this site soon. Can anyone explain the pros and cons of compiling everything in 64 bits vs 32 bits, considering the kernel will be 32 bits? I am curious as to the impact on memory usage, disk usage, etc. My initial thoughts are that 32 bits will use less memory, processing, etc. I hope to use this mini as a desktop simultaneously as a server (is this a good idea, with 4 GB of RAM?) . Am I wrong?
6:38 am
@Alex, if your kernel is not 64 bits you can’t run any 64 bits programs. Sorry…
If you have a 64 bit kernel you can run 32 bits programs, but the advantages of running 64 bits are many. Simply said your software will run much faster. We’ve done tests with mysql that show a 20% increase of performance on the same machine.
1:26 pm
Thanks for the reply richard. I am now trying to figure out how to make the mini boot into a 64 bit kernel by default. It currently boots 32 bit which i am told is needed for driver support, but it is running 64 bit software just fine.
8:56 pm
@Alex, If you need to know how to switch the kernel read: http://support.apple.com/kb/HT3773
5:21 am
Hi Richard,
Thanks for the great site. I’m having a small problem and I’m curious if anyone else has approached you with it. When I go to get the source code for MySQL 5.1.54 from the MySQL.Com web site; only rpms show up even for the Generic Architecture Independent Linux listing you referenced
They do show up properly for 5.5.8 but you can’t use configure you have to use cmake with build-options; that’s fine for me but wondered what is the best way to go.
Greg
6:40 am
@Greg, thanks for noticing this. I found this link http://downloads.mysql.com/archives.php?p=mysql-5.1&o=other to help getting (although 5.1.54 is not there but 5.1.53 is) the older versions. Still working on a how to for 5.5
6:48 am
@Richard, I’m trying to use PostfixAdmin with Snow Leopard Server… most of these services are installed by Apple (but, probably not in the right manner.) Is there any thing I should consider when following these steps?
Should I turn off the services in Server Admin and work from the console only?
9:12 am
@Ben, this setup has not been tested on OS X Server and was only meant for OS X Workstation. The only thing we have for OS X Server are a PHP upgrade and the Roundcube webmailer.