Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Repair PHP/MySQL connections in 10.4.4 System 10.4
Tiger only hintAfter updating to Mac OS X 10.4.4, you may find that the connection between PHP and MySQL running on your local webserver is broken.

Apparently the socket file got moved in the update. You can make it start working again by entering the following commands in a Terminal window:
$ sudo mkdir /var/mysql
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
[robg adds: I haven't yet update my PowerBook to 10.4.4 (since I'm using it at Expo for presentations and it's working well, I decided the 'let sleeping dogs lie' rule should be followed), so I can't confirm this one.]
    •    
  • Currently 2.67 / 5
  You rated: 2 / 5 (6 votes cast)
 
[61,128 views]  

10.4: Repair PHP/MySQL connections in 10.4.4 | 24 comments | Create New Account
Click here to return to the '10.4: Repair PHP/MySQL connections in 10.4.4' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
ln the best option?
Authored by: JayBee on Jan 13, '06 06:59:12AM

I'm always wary about making changes to the filesystem to accommodate changes in system settings like this. I discussed my solution on my blog, but the essence is to update php.ini to look for the right socket.

Basically, Apple changed the way php is compiled to make it look for the socket in /var/mysql - presumably they've made a similar change to their mysql installation in 10.4 Server? That's not the way my MySQL installation is set up, so to my mind the correct solutions are to (a) reinstall MySQL and make it use the right socket, or (b) update php.ini. I chose the latter.



[ Reply to This | # ]
ln the best option?
Authored by: Eyedea on Jan 13, '06 08:33:38AM

I followed the instructions in your blog because I couldn't get any other solution here or linked to, to work.

So MANY thanks.



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: doctype on Jan 13, '06 07:24:09AM
Apparently, the location of mysql.sock has been moved for some security reasons on MAC OS X Server and Apple uses the same php module on Client. Apple provides a Knowledge Base article:

Mac OS X Server 10.4: Issues connecting PHP to MySQL

– keep in mind, for Client, you have to turn around the settings, so either
socket=/var/mysql/mysql.sock in my.cnf, or
mysql.default_socket = /tmp/mysql.sock in php.ini

[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: beth on Jan 15, '06 07:57:34PM

I did this - changed the link to point to /tmp and it worked great!



[ Reply to This | # ]
Fix it correctly
Authored by: mholve on Jan 13, '06 07:33:00AM

Just change the path in your my.cnf config file back to /tmp...

---
Everything Solaris - http://everythingsolaris.org



[ Reply to This | # ]
compiling PHP 4.3 and PHP 4.4
Authored by: lagroue on Jan 13, '06 07:52:54AM

I had another problem with PHP/Mysql.

I compiled/built my own PHP, because I wanted to add support for GD and other graphic libraries.

The 10.4.4 update replaced my /usr/libexec/httpd/libphp4.so with its own version, and I was not really upset since I kept my PHP sources and configuration so that I could recompile it easily.

Alas, I could not figure how to compile PHP 4.3.11 again, in 10.4.4. Many horrible errors.

Fortunately, I was able to compile PHP 4.4.1.

That's what I wanted to share with you. :o)
PS (yeah PHP 4.4.2 is out since today, but it is not yet available for download)



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: darken9999 on Jan 13, '06 08:37:32AM

After two years of running OS X Server, I know this stuff all too well. If you do custom configurations (outside of Server Admin or System Preferences), or if you install/compile your own versions of pre-installed software, put it in /usr/local. You'll need to put /usr/local/bin and sbin before /usr/bin and sbin in your path, but that's the only part of the standard system that changes. In short, your software won't replace what Apple installed, but you're telling the system to use your version instead.

The MySQL binary already puts everything in /usr/local, if I remember correctly. Doing it with Apache/php is a good idea too (I use lighttpd, which I like much better). That way, when you do something funny with your php, a Software Update won't thrash your setup.



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: tforrest on Jan 16, '06 06:40:49AM
Very good point! This article does a good job of explaining 'why'

[ Reply to This | # ]
Not mine
Authored by: pub3abn on Jan 13, '06 09:16:40AM

I updated to 10.4.4, but PHP and MySQL are working just fine ... without taking this step.



[ Reply to This | # ]
Not mine
Authored by: gaoshan on Jan 13, '06 11:13:03AM

Here too. No problems with any of the various PHP/MySQL based sites I run off of my server.



[ Reply to This | # ]
Not mine
Authored by: tj2001 on Jan 13, '06 06:04:15PM

Same here.... I didn't test my sites until I ran across this hint, but nonetheless everything is fine...

What's with some issues on some systems and not others?

---
--- www.macdynamix.com ---
:: Super Me I Am ::



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: fri2219 on Jan 13, '06 02:39:04PM
This hint will reopen the security hole the 10.4.4 update was meant to close.
As others have noted, anyone having problems should follow the directions in the KB article or update their my.cnf file instead.
(I'm running my own compiled v 5.0 binary, and haven't encountered any problems with the LAMP applications I'm using.)

[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: unforeseen:X11 on Jan 14, '06 03:37:47AM

Since only PHP was having problems, but not Perl, I decided to change the path in php.ini to "/tmp/mysql.sock".

Everything runs fine now, Perl did all the time and PHP is happy again. =)

---
this is not the sig you`re looking for.



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: Elander on Jan 14, '06 07:54:54AM

If you're using PHP 5 from Marc Liyanage's site (entropy.ch), it's already configured to use /tmp/mysql.sock.

---

/elander



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: kainewynd2 on Jan 13, '06 09:51:51PM

Fixing it as doctype suggested is the easiest and most secure way to fix this issue it appears.

May I add... I love this site... I was panicking pretty heavily for a good hour before reading this hint...



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: sjk on Jan 15, '06 12:48:54AM
Are there good reasons to continue using /tmp/mysql.sock instead of /var/mysql/mysql.sock after reading this hint and knowing now that the former is less secure than the latter? Seems to me that's undoing Apple's intended fix in 10.4.4 (Server):

Mac OS X Server 10.4.4: Improvements to Apache/PHP/MySQL interaction

... and also the /usr/libexec/httpd/libphp4.so update (sorry, lagroue) on Client to use that path:

'--with-mysql-sock=/var/mysql/mysql.sock'

I'm not saying it's right or wrong, just hoping to understand anything I might have missed. Thanks.

[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: TvE on Jan 15, '06 02:50:58AM
Are there good reasons to continue using /tmp/mysql.sock instead of /var/mysql/mysql.sock

no - it only makes your system less secure, as stated earlier in this thread. Kind'a like putin' a band-aid on a broken arm

[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: sjk on Jan 16, '06 01:31:59PM

Right, which is why I'm still puzzled that several people here apparently want to make their systems less secure by using the deprecated socket pathname. Are they misunderstanding the warnings or knowingly ignoring them?



[ Reply to This | # ]
Another way ?
Authored by: nebulus on Jan 16, '06 04:45:37AM

I have found another possibility to fix this : change the host url in the config file of the applications using mysql.

I only use phpMyAdmin and Drupal in development on my mac. And in their configuration files the host reference was "http://localhost/some_local_dir". Thus, I replaced localhost by the loopback IP 127.0.0.1, resulting in "http://127.0.0.1/some_local_dir" and everything was working back.

I'm not sure it is a "good" practice, but it worked for me.



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: bloodycelt on Jan 16, '06 07:09:58AM

I installed MySQL 5.0 in /opt/local
and it looks for the socket in /opt/local/mysql.sock

this is the mysql client... not the php.
So i followed the hint (for now) any other suggestions about configuring the client to use /tmp/mysql.sock?



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: brainerwm on Jan 27, '06 07:41:25AM
I chose to follow the Apple hint and use /var/mysql/mysql.sock on MacOSXclient10.4 since it is supposed to be more secure. I made a file called /etc/my.cnf which contained:


[mysqld]
socket=/var/mysql/mysql.sock

...and I updated permissions as described:


>sudo chmod 775 /var/mysql

That worked fine.

The next problem, which I haven't seen mentioned here, was that the mysql and mysqladmin commands didn't work in terminal as they were still looking for /tmp/mysql.sock. Adding the client group to /etc/my.cnf solved it:



>echo "[client]" >> /etc/my.cnf
>echo "socket=/var/mysql/mysql.sock" >> /etc/my.cnf

My fully working /etc/my.cnf file now looks like:


[mysqld]
socket=/var/mysql/mysql.sock
[client]
socket=/var/mysql/mysql.sock

Here is mysql.com's useful page about /etc/my.cnf.

[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: Globulator on Feb 03, '06 01:35:52AM

The reason you must not use /tmp/mysql.sock is that any Tom, Dick or Other can simply delete it and bring your php-mysql system down.

The fix is actually simple:
sudo mkdir -p /var/mysql
sudo chgrp mysql /var/mysql
sudo chmog g+w /var/mysql

edit/create /private/etc/my.cnf and add the line:
socket=/var/mysql/mysql.sock

restart mysql

now the new php wil find the socket info in the right place, if you change php then you might need to tell that about the new secure location.



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: MAbans on Feb 04, '06 04:18:28PM

IMPORTANT! After trying to make it run for hours I realized that I created the "/mysql" folder the owner was root so make sure you run

[code]
sudo chown mysql /var/mysql
[/code]

Just incase it doesn't let you in because of wrong owner. Don't make the mistake I made. Woot!



[ Reply to This | # ]
10.4: Repair PHP/MySQL connections in 10.4.4
Authored by: jsamlarose on Apr 27, '06 09:07:23AM

Took me ages to figure this out... the thing that worked for me was updating the php.ini file, and changing the line

mysql.default_socket =

to

mysql.default_socket = /tmp/mysql.sock

In my case, I had php.ini.default, and couldn't figure out why phpinfo wasn't reflecting the changes I made to the line, until I learned that I needed to resave php.ini.default as php.ini. Et voila - it worked.

Additional links I found helpful

http://docs.info.apple.com/article.html?artnum=302977
http://blog.johnjosephbachir.org/index.php?p=122

If, like me, you read through all the things posted on this page and still couldn't get it, these pages may help you out.



[ Reply to This | # ]