PHP/MySQL Broken After Security Update 2010-05; Fix

August 25, 2010

Mac

After applying Security Update 2010-05, some users have reported PHP and MySQL problems, including an inability to connect to MySQL databases.

Apple Discussions poster TriangleJuice reports that the following procedure resolves the database connection issue:

  1. In the Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password)
  2. Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock
  3. Press Ctrl-O, then Enter to save
  4. Type sudo apachectl graceful
, , , , , , ,

Enjoyed this Post?

Subscribe to our e-mail newsletter to receive updates, follow us on Twitter or simply recommend us to friends and colleagues!

16 Responses to “PHP/MySQL Broken After Security Update 2010-05; Fix”

  1. otolithe Says:

    Thanks for the tip, I sort of freaked out when I opened the local instance of the web app I’m currently developing for a client and saw the dreaded “cannot connect” PHP messages!

    Reply

  2. Andrew Stone Says:

    PHP.ini isn’t located at “/etc” in either 10.5 or 10.6.

    Use the “locate” app in Terminal and you will see.

    Both PHP and MySQL are fine on my install of 10.6.

    I would proceed with caution on this tip.

    Reply

  3. TriangleJuice Says:

    Hi Andrew,

    you’re kinda right: if you just have a default php install, then you will only find a “php.ini.default” file. You first have to duplicate that file into “php.ini” (use “cp” in Terminal), then follow the rest of my hint above.

    Please, let me know if there any other problems!

    Reply

  4. Michael Says:

    While the files may live in /private/etc/php.ini* you can edit /etc/php.ini and the changes will be made to /private/etc/php.ini and vice-versa. Try it.

    I’m still unable to get anything working even with proper changes in */php.ini.

    Reply

  5. Pieter Says:

    Thanks, this tips worked fine for me. Now, my website is available again.
    Apple, thank you for this glitch, this is the second one after an update.

    Reply

  6. Baseline Says:

    I’m also having issues with MySQL and PHP after security update. Local connections appear to work but remote does not.

    Reply

  7. Baseline Says:

    I am using Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 PHP/5.3.2 on Mac OSX10.6.4. I am using Xataface a PHP Interface Generator for MySQL. After applying Security Update 2010-005 Xataface became inoperable though I could still use Sequel Pro to access MySQL. The installation I have is pretty basic and follows most of the default settings. I had no php.ini file.
    So with the use of terminal:
    Step 1: (Optional) Navigate to Root Directory (Using cd)
    Step 2: (Optional) Set Up ‘Locate’ Database
    I had to first search using the command ‘locate’ and as this was a first use of this command the locate database had to be populated so I had to use the command:
    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
    Step 3: (Optional)Type the Command:
    sudo locate php.ini
    This provide me a path to a file called php.ini.default which was located in the directory called /private/etc/
    Step 4: Navigate to directory /private/etc/ (Using cd)
    Step 5: Verify that php.ini does not exist in this directory. (If one already exists it would pay to keep a backup of this file prior to modifying)
    Step 6: Copy php.ini.default to php.ini by typing:
    sudo cp php.ini.default php.ini
    Step 7: Open the php.ini file in Nano by typing
    sudo Nano php.ini
    Step 8: Use the command ctrlW to find the entry for mysql.default_socket and change it so that it reads as follows:
    mysql.default_socket = /tmp/mysql.sock
    Step 9: Exit from Nano by using ctrlX and choosing yes to save.
    Step 10: Type the command:
    sudo apachectl graceful

    After following this procedure I found that PHP could connect back to MySQL.

    Many thanks to TriangleJuice for providing some clues.

    However I suspect this solution is not correct in that it seems to reinstate a configuration file that was not being used previously, namely php.ini. I note that there seems to be many settings within this file that I have not yet reviewed. I would have preferred to have identified and corrected the configuration settings that the default installation was using.

    Reply

  8. Elliot Says:

    As Michael says, the file is a symlink, so we’re OK to edit either one. Also, this tip has fixed a problem introduced by the Security Update 2010-05 for me, exactly as described.

    I already used the php.ini file to customise the timezone of PHP; TriangleJuice is correct in suggesting that you would only have this file if you have made similar customisations yourself.

    Reply

  9. Gabriel Says:

    This was a perfect tip, thank you very much. Just what I was looking for after I too noticed that after the OS X update my local database connections weren’t working. Followed the steps and everything is working correctly again.

    Thanks again,
    Gabriel

    Reply

  10. ScottKB Says:

    Thanks TriangleJuice, your tip worked for great for me. Sites back online.
    OS10.6.4
    MySQL 5.1.43
    PHP 5.3.2

    Reply

  11. Mike Says:

    Great tip…

    I wasn’t sure I wanted to edit the php.ini file – so I copied php.ini.default to php.ini and instead of changing the defaults, I create a symlink in /var to /tmp

    sudo ln -s /tmp /var/mysql

    this just worked.

    Reply

  12. Jeremy Says:

    I suspect you should also change the pdo_mysql.default_socket variable to pdo_mysql.default_socket=/tmp/mysql.sock

    Reply

  13. NICCAI Says:

    I’m having this issue again with security update 2010-006, however this fix no longer works. Any suggestions?

    Reply

  14. include Says:

    thanks to jeremy. problem solved.

    Reply

  15. Amanda Says:

    Sorry to have to ask (hand holding here) but I’m no programmer- my wireless connection won’t show after installing the security update 2010-007 for OS X 10.5 (running on a Macbook Pro) even though the modem and router are working just fine. What gives? Any ideas?

    Reply

Leave a Reply