Note: For a much simpler, clearer, better tutorial on all this, please see “Working with PHP 5 in Mac OS X 10.5 (Leopard)”.

These notes are based on my experience installing and configuring mySQL and phpMyAdmin on my Mac (Dual PowerPC G5 / OS X 10.4.11). Maybe they’ll also be helpful to you. They are no substitute for the “official” installation instructions. They are strictly “as-is”. Use at your own risk. Mileage may vary, etc.

Preliminaries:
  1. Make sure your local web server is turned on. (Open the “Sharing” panel in your System Preferences, and make sure the “Personal Web Sharing” item is checked. Note: this is where you can also change your computer’s name.)
  2. Point your browser to http://localhost . If you haven’t already configured a local website, you’ll get the default Apache web page (~/Sites/index.html).
Installing mySQL
  1. Get the latest version.
  2. Double-click the .dmg file to mount the mySQL disk image
  3. There are two mySQL packages in the disk image file. Double-click the one named mysql-foo.pkg, where foo contains this mySQL version number and your OS.
  4. Follow the installer instructions. This installs mySQL in /usr/local/mysql
  5. Add /usr/local/mysql/bin to your shell’s search path (if you don’t know how to do this, see the ReadMe.txt file).
  6. In Terminal:

    % sudo /usr/local/mysql/bin/mysqld_safe # (enter password, if asked)
    % ^Z # suspend the daemon
    % bg # resume daemon as a background task

  7. Create mysql’s “root” user. In Terminal:

    % sudo mysqladmin -u root password somePassword

    Here “somePassword” is a password for mysql’s “root” user. This “root” is not the same as the system’s “root” user. Go figure. Read Apple’s docs for more details.

  8. Test the installation. In Terminal:

    % mysql -u root somePassword # test mysql

    This should spit out a list of mysql options and variable settings. If not, you’ll have to find some more in-depth docs. (Start with the ReadMe.txt.) Sorry.

Installing PhpMyAdmin
  1. Get the latest version.
  2. Unzip the file into ~/Sites .
  3. This creates a directory with a long and hard-to-remember name. Rename it phpMyAdmin.
  4. In Terminal:

    % cd ~/Sites/phpMyAdmin
    % mkdir config # create directory for saving
    % chmod o+rw config # give it world writable permissions

  5. Point your browser to http://localhost/~YOURUSERNAME/phpMyAdmin
  6. You should see a “Welcome to phpMyAdmin” page. It will probably contain an “Access denied” error message because you haven’t created a config file. Click on the link to the “setup script”.
  7. In the “Servers” row, click the “Add” button. To avoid having to enter a password each time you run phpMyAdmin, enter the mySQL “root” password in the “Password for config auth” field. You can accept all the other defaults. Click the green “Add” button.
  8. Click the “Save” button in the “Configuration” row.
  9. In terminal:

    % cd ~/Sites/phpMyAdmin
    % mv config/config.inc.php .

    The phpMyAdmin docs go further, and ask you to do this:

    % chmod o-rw config.inc.php # remove world read and write permissions

    But when I do that, phpMyAdmin is denied access. Since I’m hiding behind a firewall I’m not going to worry about those permissions right now….

If you point your browser to http://localhost/~YOURUSERNAME/phpMyAdmin you might get this error message:

MySQL said:
#2002 - The server is not responding
(or the local MySQL server’s socket is not correctly configured)

If so, do the following (courtesy of Ben VanScoter):

% sudo mkdir /var/mysql
% sudo ln /tmp/mysql.sock /var/mysql/mysql.sock
% sudo apachectl graceful
/usr/sbin/apachectl graceful: httpd gracefully restarted
%

Works for me.

Now you’ll be able to create and manage mySQL databases using phpMyAdmin, to your heart’s content.