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:
-
- 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.)
- 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
-
- Get the latest version.
- Double-click the
.dmgfile to mount the mySQL disk image - There are two mySQL packages in the disk image file. Double-click the one named
mysql-foo.pkg, wherefoocontains this mySQL version number and your OS. - Follow the installer instructions. This installs mySQL in
/usr/local/mysql - Add
/usr/local/mysql/binto your shell’s search path (if you don’t know how to do this, see theReadMe.txtfile). - In Terminal:
% sudo /usr/local/mysql/bin/mysqld_safe # (enter password, if asked)
% ^Z # suspend the daemon
% bg # resume daemon as a background task - 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.
- 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
-
- Get the latest version.
- Unzip the file into
~/Sites. - This creates a directory with a long and hard-to-remember name. Rename it
phpMyAdmin. - In Terminal:
% cd ~/Sites/phpMyAdmin
% mkdir config # create directory for saving
% chmod o+rw config # give it world writable permissions - Point your browser to http://localhost/~YOURUSERNAME/phpMyAdmin
- 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”.
- 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.
- Click the “Save” button in the “Configuration” row.
- 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.