PHP, MySQL and phpMyAdmin, on my Mac, Oh My!

I recently updated the web application hosting environment on my Mac (Leopard, 10.5.6 as of this writing) in order to support a local copy of Drupal. I have a local copy of TWiki, which is the wiki software we use the most at work, but as I begin using Drupal more and more, I decided to start using it for my personal writing as well.

In order to support I Drupal I had to install MySQL and update PHP. Mac OS X does ship with PHP already installed, but it hasn’t been updated in quite a while. Apache is also shipped with OS X, and didn’t require updating at this time.

To start off, I installed the latest version of MySQL, which in the end turned out to be a mistake.

After installing phpMyAdmin, I received the following error:

Your PHP MySQL library version 5.0.45 differs from your MySQL server version 5.1.32. This may cause unpredictable behavior.

I then updated PHP per these instructions.

After the update, I still had the error, but the library version was now 5.0.77. Newer, but still not the same version as MySQL server.

At this point I could have (probably, it’s not trivial) installed PHP by compiling from source, but I had another idea in mind.

To make a long story short, I uninstalled MySQL and then downloaded and installed version 5.0.77.

After restarting Apache, the version mismatch warning noted by phpMyAdmin was gone!

There was one other trick required to get MySQL and phpMyAdmin to work. After the initial installation of both programs, I received the following error (even before the library/server version mismatch error):

The server is not responding (or the local MySQL server’s socket is not correctly configured)

Doing the following in a terminal window fixed things right up:

sudo mkdir /var/mysql
sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

Thanks to Mike Brenner in the MySQL forums for that tip.

Other things I discovered along the way:

Start/Stop Mysql

Typically, MySQL is started when the system reboots. When testing it’s often necessary to stop and restart as needed; the following commands make this easy to do:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

These can be aliased nicely:

alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"

Thanks to Simplistic Complexity for that one.

The featured image (which may only be displayed on the index pages, depending on your settings) was randomly selected. It is an unlikely coincidence if it is related to the post.

5 thoughts on “PHP, MySQL and phpMyAdmin, on my Mac, Oh My!”

  1. Hi Mike,

    I also have an iMac and went through similar issues as you updating php, MySQL etc for a local Drupal development system on the Mac.

    In the end, I went for the easy route an install MAMP (www.mamp.info) which is MUCH easier and includes a nice dashboard widget to start/stop your services.

    (PS. I like the design of your site – nice job).

    Adam

  2. I’m also getting those various errors in PHPMyAdmin.

    Managed to update PHP using the link you give – thanks.

    But: any idea where to get MySQL Server version 5.0.77?

    The only version I can see on the MySQL website is 5.0.83. And I’m guessing that if I install that I’ll get that error between the PHP MySQL library and the MySQL server again…

  3. Hi Mike,

    Thanks SO much for providing that suggestion for fixing the “Server is not responding” error I’d been getting on my Mac. I’d been working on trying to correct it for a couple of hours when I came across your suggestion and it worked perfectly.

    Jenny

Comments are closed.