Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

PHP/MySQL issue after security update 2010-005

Hello,

I run Apache/PHP/MySQL on my MBP for testing Web sites.
After the 2010-005 security update I can't connect to my databases anymore.

I don't know how to fix this, I even don't know where to start looking.

Ideas, anyone?

Posted on Aug 25, 2010 7:13 AM

Reply
19 replies

Aug 25, 2010 8:16 AM in response to RobBT

I had the same problem and fixed it by editing my php.ini file:

1. In 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. Still in Terminal, type sudo apachectl graceful

5. That's it!

Don't worry if this didn't work for you, just repeat the steps, described from above, only delete the "/tmp/mysql.sock" part again from the php.ini file 🙂

Aug 26, 2010 12:54 PM in response to RobBT

Worked for me too. I had to copy the php.ini.default file to php.ini, then change the mysql.sock setting in three places. In the default file it is set to /var/mysql/mysql.sock. It needs to be changed to just /tmp/mysql.sock without the extra 'mysql' sub directory.

Many thanks for pointing this out. I spent a couple of hours of wasted time before I found this post. Most helpful and I am most grateful.

Aug 26, 2010 5:08 PM in response to RobBT

It looks like Apple's old build of PHP used both /var/mysql/mysql.sock and /tmp/mysql.sock for different modules. The new build makes things more consistent and uses only only /var/mysql/mysql.sock. However, the default socket for MySQL is still /tmp/mysql.sock.

I like to use defaults whenever possible. I find it much easier to debug config files when they don't exist. What I did was change my MySQL launchd file. I replaced:

<key>Program</key>
<string>/usr/local/mysql/bin/mysqld_safe</string>

with

<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld</string>
<string>--socket=/var/mysql/mysql.sock</string>
<string>--basedir=/usr/local/mysql</string>
<string>--datadir=/usr/local/mysql/data</string>
<string>--user=mysql</string>
<string>--log-error=/usr/local/mysql/data/Pele.local.err</string>
<string>--pid-file=/usr/local/mysql/data/Pele.local.pid</string>
</array>

(which is mostly what mysqld_safe used to do, with the addition of --socket).
(I could have done this in a number of different ways. This is just one example.)

Now, everything works and I still have no config files.

Aug 28, 2010 9:44 PM in response to TriangleJuice

Thanks, mr. juice! 🙂

My php.ini file didn't have a line to define the mysql socket, so I just added your one line at the end of the mysql configuration section:

mysql.default_socket = /tmp/mysql.sock

Also, since I have BBEdit, I edited the file by choosing "open file by name" and giving it /etc/php.ini -- a little simpler for those of us who are not nano users.

Donna

Aug 28, 2010 9:49 PM in response to etresoft

etresoft, thanks for sharing this ... I decided to go with the TriangleJuice suggestion instead for two reasons ... first is that I wasn't sure where to find this launchd file.

I also don't have a /var/mysql directory and wasn't sure whether I should just create one or if this meant my configuration was different. If you feel like explaining any of this, I'd be curious to know.

thanks!
Donna

Aug 29, 2010 11:02 AM in response to RobBT

For me this can't work...
I can't understand why I can't connect.

I've followed all the istructions you gave but without any results.
I have this line: pdo mysql.defaultsocket=/var/mysql/mysql.sock

i've edited in pdo mysql.defaultsocket=/tmp/mysql.sock with no results so i used mysql.default_socket=/tmp/mysql.sock but also the connecton failed.
i edited again in mysql.default_socket=(without /tmp/mysql.sock) and then pdo mysql.defaultsocket=(without /tmp/mysql.sock) but it didn't work!

sombody can halp me?

Message was edited by: Bofors78

Aug 29, 2010 11:23 AM in response to coloma

coloma wrote:
etresoft, thanks for sharing this ... I decided to go with the TriangleJuice suggestion instead for two reasons ... first is that I wasn't sure where to find this launchd file.


There is nothing wrong with TriangleJuice's suggestion. My only issue with creating a php.ini file is that now I have to worry about all those other settings in the ini file. If something else in PHP breaks, I have to figure out if I am the one who broke it.

Apple ships MySQL with MacOS X Server. They probably adjusted the PHP settings to match how they have MySQL setup in MacOS X Server.

For MySQL's, no, Sun's - drat! no, Oracle's part, they still haven't acknowledged the fact that Apple has shipped MacOS X 10.4. MySQL still ships with a Startup Item. If you don't know where the launchd file is, it is because you don't have one. You probably have a MySQL entry in /Library/StartupItems or maybe /System/Library/StartupItems. Startup Items were deprecated in 10.4. Oracle should be creating a file named com.mysql.mysqld.plist in /Library/LaunchDaemons.

Here is what mine looks like now:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld</string>
<string>--socket=/var/mysql/mysql.sock</string>
<string>--basedir=/usr/local/mysql</string>
<string>--datadir=/usr/local/mysql/data</string>
<string>--user=mysql</string>
<string>--log-error=/usr/local/mysql/data/Pele.local.err</string>
<string>--pid-file=/usr/local/mysql/data/Pele.local.pid</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>


I also don't have a /var/mysql directory and wasn't sure whether I should just create one or if this meant my configuration was different. If you feel like explaining any of this, I'd be curious to know.


You have to create one. Such a directory probably already exists on MacOS X Server. Just make sure it is owned by mysql.

sudo mkdir /var/mysql
sudo chown _mysql:staff /var/mysql
sudo chmod 0755 /var/mysql
[jdaniel@Pele:516] /var $ ls -al /private/var | grep mysql
drwxr-xr-x 3 _mysql staff 102 Aug 26 20:03 mysql


Of course, /var is a symbolic link to /private/var. Long story there.

Aug 29, 2010 12:14 PM in response to etresoft

Thanks for your post!
You suggested me the solution i needed!

I create the directory /var/mysql anche inside a link to /tmp/mysql.sock:

*sudo mkdir /var/mysql*
*sudo chown _mysql:staff /var/mysql*
*sudo chmod 0755 /var/mysql*
*cd /var/mysql*
*sudo ln /tmp/mysql.sock mysql.sock*

So i solved all my problems using the unmodified file php.ini!

Thanks at all!!!

Aug 31, 2010 7:14 PM in response to RobBT

While investigating this issue, I explored my "standard" Snow Leopard Server installation (i.e., no custom installations of third-party open source packages). With MySQL running, I examined /var/mysql and /tmp/ to discover that MySQL's socket is in /var/mysql, and /tmp/ is essentially empty. PHP functions properly and can communicate with MySQL.

So I have to ask: for those sites no longer able to connect to MySQL, are you using the default MySQL installation that comes with X Server or a custom version from elsewhere (that perhaps you hand-built)?

(For those using /tmp/ with a custom version, may I humbly recommend you switch to /var/mysql instead as /tmp/ is insecure and is susceptible to various security attacks.)

Thanks in advance for the feedback.

Sep 1, 2010 7:54 AM in response to etresoft

Hello etresoft,

After resolving the issue promptly with TrianleJuice's solution I read your posts with phrases like:
+I like to use defaults whenever possible. I find it much easier to debug config files when they don't exist.+ And: +My only issue with creating a php.ini file is that now I have to worry about all those other settings in the ini file.+ Which should appeal to all Mac users.

I keep your solution on file to apply it one of these days.

Thank you.

PHP/MySQL issue after security update 2010-005

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.