Installing MySQL and PHPMyAdmin on a Mac

Part of making OS X 10.6 (Snow Leopard) a great LAMP development platform is installing MySQL. Here’s how to install that along with the most popular web interface for managing MySQL, PHPMyAdmin.

1. Download the Mac OS X 10.5 (x86_64) package format from  The downloaded file should be named mysql-5.1.xx-osx10.5-x86_64.dmg with “xx” replaced with a minor release number.  Open it and see something like this:

2. Double click the mysql-5.1.xx-osx10.5-x86_64.pkg and install it with the defaults.

3. Do the same for MySQLStartupItem.pkg.

4. Double click MySQL.prefPane and follow the instructions to add the MySQL pane to your System Preferences.

5. Open System Preferences -> MySQL and start MySQL.  Check “Automatically Start MySQL Server on Startup” unless you want to restart it with this panel manually every time you reboot.

We’re done with MySQL.  Now lets download and install PHPMyAdmin.

6. Download the PHPMyAdmin .bz2 file from  Put it in the Sites folder (under your home folder).  Double click it in Finder to unarchive it.  Rename the folder it creates to phpMyAdmin (just removing the version info to make it easier to remember).  Now for the trickiest part.  Edit the Apache configuration files.

7. Edit system file /etc/apache2/httpd.conf and just remove the # from the line that includes the httpd.vhosts file.  From now on whenever I say “edit system file” that means use sudo and your favorite editor.  (I use vi but I would never recommend that unless you want to learn a powerful but very obscure and difficult to learn editor.)  If you’re not sure how to edit a system file try this.  Open Terminal (Applications -> Utilities -> Terminal) and enter this command to edit system file /etc/apache2/httpd.conf:

sudo nano /etc/apache2/httpd.conf

When it asks for a password, enter your OS X login password.  Look at the hints at bottom of the Terminal figure out how to write the file with your changes and exit the editor.

Should look like this when you’re done:

Include /private/etc/apache2/extra/httpd-vhosts.conf

8. Edit system file /etc/apache2/extra/httpd-vhosts.conf and replace the VirtualHost example blocks with this (replacing roger with your own username):

<VirtualHost *:80>
DocumentRoot /Users/roger/Sites/phpMyAdmin
ServerName phpMyAdmin.localhost
ErrorLog “/private/var/log/apache2/phpMyAdmin.localhost-error_log”
CustomLog “/private/var/log/apache2/phpMyAdmin.localhost-access_log” common
<Directory “/Users/roger/Sites/phpMyAdmin”>
AllowOverride All
Allow from All

9. Edit system file /etc/hosts to add the local domain name for your PHPMyAdmin site.  Just add this line to the file:     phpMyAdmin.localhost

10. Now just restart the web server with the new configuration with this command:

sudo /usr/sbin/apachectl restart

11. Open your browser and visit http://phpMyAdmin.localhost to experience the victory and start managing your databases.

I think these instructions should work just as well on 10.5 (Leopard).

Good luck and post a comment if you need any help.

Be Sociable, Share!

10 thoughts on “Installing MySQL and PHPMyAdmin on a Mac

  1. I am running OSX10.6. Just downloaded mysql version for 10.6. Getting back to normal having upgraded the OS!!
    Thanks for your article in installing phpMyAdmin. Question is do I add another include statement in the Apache config file or edit the existing one.

  2. peter, edit the existing one.

    Btw, since I wrote this I became a fan of macports ( Now use that system for installing PHP, MySQL, etc. Installations are easier to manage with macports but you have to look for all their files in /opt/local rather than the default directories.

    Good luck and let me know how it goes.

  3. Thanks for the great guide very clear for a beginner. Just one question about installing phpmyadmin. When I uncommented the line:
    Include /private/etc/apache2/extra/httpd-vhosts.conf
    it didn’t work (i just got a browser page not found). But it works when I DO comment out the line, contrary to your instructions. Why could that be?

    (am using snow leopard).

  4. Gus, that line uncommented in step 7 is simply including the file that is edited in the next step, so this must mean there is an error in the next step, 8.

  5. Hi
    Thanks for the setup advice. I am setting it up on Snow Leopard (a fresh install).
    I have checked your instructions BUT I may have done something wrong!
    When typing into the browser I get a 403 forbidden stating I do not have permission/access to the server.
    I have set the account up as administrator and have root access.
    I wonder if you could suggest a solution?

  6. Hi there,
    Great right-up. I had problems with apache loading any of my local sites after following this walk-though. I apachectl -t to see whats up and it had problems with multi-directory settings. For some reason directly copying the settings in nano caused the “” to change. I fixed those and now all is fine.

Comments are closed.