PHP
MySQL
Ok, it's actually PHP 4.4.7 and MySQL 5.0.x!
On my Mac Mini (Intel) I've got Mac OS X 10.4.10 and it comes with it's own Apache Server, in fact all Mac OSX distributions have Apache built in.
I don't remember, but apparently sometime I had installed PHP 4.4.7 and PHP 5 (to use both) I wanted to get MySQL on it because I wanted to start developing some serious web stuff locally...
Since the unfortunate total disappearance a month ago of the last web host I had used... and subsequently lost everything I was working on because I was developing it on their server(s) -- Bad mistake: Not backing anything up just because I didn't have MySQL!
So I got the latest MySQL 5.0.45 release for Mac OS X in the easy installer package format.
PHPMyAdmin
I proceeded to install it and checked to see if it worked with PHP 5 using PHPMyAdmin.
AND... Giddy it worked!
Now I go into the Terminal.app Unix Shell Application and type:
sudo cp /etc/httpd/php4.httpd.conf /etc/httpd/httpd.conf
Switch to PHP 4 and reload the PHPMyAdmin... And I'm Greeted with:
Error
MySQL said:
#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
What On Earth!!
I have no idea what that really means...
So I spent the good part of four days researching and trying a bunch of crap to get it to work... by changing the php.ini file by changing the line...
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =
TO:
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =/tmp/mysql.sock
Restart the Apache Server and try to reload PHPMyAdmin...
And to no avail I still see...
Error
MySQL said:
#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
So after taking a break and coming back I think of linking the mysql socket to where PHP 4 is looking for it....
mysql
MySQL Support | enabled |
Active Persistent Links | 0 |
Active Links | 0 |
Client API version | 4.1.22 |
MYSQL_MODULE_TYPE | external |
MYSQL_SOCKET | /var/mysql/mysql.sock |
MYSQL_INCLUDE | -I/usr/include/mysql |
MYSQL_LIBS | -L/usr/lib/mysql -lmysqlclient |
... In... /var/mysql/mysql.sock
And The info for PHP 5, which works with MySQL is:
mysql
MySQL Support | enabled |
Active Persistent Links | 0 |
Active Links | 0 |
Client API version | 5.0.19 |
MYSQL_MODULE_TYPE | external |
MYSQL_SOCKET | /tmp/mysql.sock |
MYSQL_INCLUDE | -I/usr/local/php5/include/mysql |
MYSQL_LIBS | -L/usr/local/php5/lib/mysql -lmysqlclient |
So why not create an alias linking /var/mysql/mysql.sock
to /tmp/mysql.sock
Not being so fluent in Unix Command-Line stuff, I struggled to figure out how to do this and found this site... Here's what I did (the clean and easy to follow version):
- Create 'mysql' folder in /var/
- Create A Link Of /tmp/mysql.sock As /var/mysql/mysql.sock
- Restart The Apache Server
The Commands:
$ sudo mkdir /var/mysql/
$ sudo ln /tmp/mysql.sock /var/mysql/mysql.sock
$ sudo apachectl graceful
/usr/sbin/apachectl graceful: httpd gracefully restarted
And ooh-la-la it works!
Sure it's probably a bit unorthadox, and PHP 4 only has Client API for 4.1.22... but MySQL doesn't change much on the front-end I'm assuming so it should be pretty good.
Everything was confirmed working after creating and editing the same table in MySQL 5 using PHP 4 and PHP 5
Update:
It has come to my attention that though the above may work... it may not work as well as it should...
Because I've run into the instance where the link I would create using $ sudo ln /tmp/mysql.sock /var/mysql/mysql.sock
would disappear from /var/mysql/mysql.sock
when switching from PHP 4 to PHP 5 and back to PHP 4 again after I restart somewhere in between I think.
I'm not sure where it is breaking down... but there's a couple more robust solutions that I'd suggest... and that is to change the standard link using the ln
command to a symbolic link using the ln -s
command in terminal.
So now the commands would now be:
$ sudo mkdir /var/mysql/
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
$ sudo apachectl graceful
/usr/sbin/apachectl graceful: httpd gracefully restarted
Or you can do what I did, and just make the folder /var/mysql
a symbolic link... which is a little less work:
$ sudo ln -s /tmp/ /var/mysql/
$ sudo apachectl graceful
/usr/sbin/apachectl graceful: httpd gracefully restarted
Note: if you want to do the above there can't be a folder /var/mysql/
already, you'll need to delete it. This can be done using:
$ rm -r /var/mysql/
These commands should work better because of the difference between a hard link and a symbolic link...
A hard link (ln
) disappears if the linked-to file disappears... and a symbolic link (ln -s
) remains even if the linked-to file disappears and for this situation is what we need since mysql.sock
seems to disappear somewhere along the lines of a restart or as described above.
Plus, since symbolic links allow you to have a folder point to another destination folder you can do $ sudo ln -s /tmp/ /var/mysql/
Disclaimer: I take no responsibility for what happens to your system if you use these instructions. Though I have been able to use this methods successfully your results may vary. It is highly advisable you backup any files before changing or modifying them.
Click Here To Read The Full Article By Itself.