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:
- In the Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password)
- Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock
- Press Ctrl-O, then Enter to save
- Type sudo apachectl graceful





August 26, 2010 at 6:22 AM
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!
August 26, 2010 at 7:46 AM
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.
August 27, 2010 at 4:07 AM
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!
August 27, 2010 at 12:11 PM
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.
August 28, 2010 at 1:46 AM
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.
August 29, 2010 at 3:51 AM
I’m also having issues with MySQL and PHP after security update. Local connections appear to work but remote does not.
August 29, 2010 at 6:02 AM
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.
August 29, 2010 at 9:46 AM
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.
August 31, 2010 at 4:23 PM
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
September 1, 2010 at 3:29 AM
Thanks TriangleJuice, your tip worked for great for me. Sites back online.
OS10.6.4
MySQL 5.1.43
PHP 5.3.2
September 3, 2010 at 5:55 AM
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.
September 4, 2010 at 6:17 AM
I suspect you should also change the pdo_mysql.default_socket variable to pdo_mysql.default_socket=/tmp/mysql.sock
October 6, 2010 at 1:10 AM
I’m having this issue again with security update 2010-006, however this fix no longer works. Any suggestions?
October 8, 2010 at 11:55 AM
same here
October 8, 2010 at 1:25 PM
thanks to jeremy. problem solved.
November 28, 2010 at 6:13 PM
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?