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.

March 29th, 2009|Categories: MacStuff, Technology|5 Comments

5 Comments

  1. Adam April 4, 2009 at 10:06 am

    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. Ben Hayes June 24, 2009 at 9:50 am

    D’oh! Found it here afterall.

  3. Ben Hayes June 24, 2009 at 9:43 am

    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…

  4. Jenny Robbins July 29, 2009 at 12:42 pm

    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

  5. Mac Eclipse Setup March 29, 2009 at 9:54 pm

    […] successfully resolved my PHP, phpMyAdmin and MySQL issues, I next turned to the task of getting the Eclipse software development environment up and running […]

Comments are closed.