how to fix mySQL problems in OSX due to 10.4.4 update
A few days ago I noticed that mySQL on my Powerbook stopped working. It struck me as odd, since I didn’t make any recent changes to the mySQL configuration. It was as if one day mySQL worked, then it didn’t.
Turns out that Apple’s OS update 10.4.4 (released January 10th 2006, right after the MacWorld Expo) changed how mySQL connects to PHP. More info here.
For the benefit of others who might have a similar problem, I’ll detail the steps I took to get mySQL back up and running.
Before starting, make sure you are running 10.4.4 on OSX AND that you didn’t do anything to break it other than upgrade to 10.4.4
My symptoms were:
- PHP scripts worked
- PHPmyAdmin (mySQL database manager) threw a “can’t connect to local mysql server through socket” error
The reason for the problem:
When PHP is communicating with a MySQL server on the same host, it uses a socket file to communicate, and looks for it at /tmp/mysql.sock. You need to make sure PHP knows where to find mySQL socket. Here’s how to do it:
First, open the Terminal application.
Type the following, which creates a file called php.ini from the file php.ini.default:
sudo cp /etc/php.ini.default /etc/php.ini
Next, open php.ini in a text editor. I use pico. It’ll open in the Terminal window as well. You can open php.ini with pico using the following command:
pico /etc/php.ini
Then, look for the following section under the header [MySQL]:
; Default socket name for local MySQL connects. If empty, uses
the built-in
;MySQL defaults.
mysql.default_socket =
Change it so that mysql.default.socket points to /tmp/mysql.sock, like so:
; Default socket name for local MySQL connects. If empty, uses
the built-in
;MySQL defaults.
mysql.default_socket = /tmp/mysql.sock
Save your changes by pressing ctrl-o (Write Out)
Exit pico by pressing ctrl-X.
Restart Apache so that changes take effect by entering the following:
sudo apachectl graceful
Now go check your local webserver, and run some PHP scripts that query mySQL. Everything should work as it did before the OS update.
1 Comment
RSS feed for comments on this post.
this doesn’t appear to work on 10.4.11, problem still exists