MJN1812 wrote:
Came across this in support:
Summary
Mac OS X Server 10.4.4 resolves two issues with the default interaction between the versions of PHP and MySQL that are pre-installed on Mac OS X Server:
Just ignore this for now. Before you go any further, though, do this: open BBEdit and make sure the command line tools are installed. Look under the "BBEdit" menu item and choose "Install Command Line Tools..." from there. Having those installed will make editing some of the configuration files a lot easier.
These instructions should get you up and running:
1. First, determine if MySQL is actually running or not. Open the Terminal application and execute this command:
ps aux | grep mysqld | grep -v grep
If it's running, you should get a couple of lines of output starting with "
_mysql". If it's not running then don't worry about stopping it. If it is running, then stop here and post the two lines you get, along with the results of this command:
sudo launchctl list | grep mysql
2. Assuming the daemon isn't running, let's use BBEdit to create a MySQL configuration file that makes sure the socket is where we want it. From Terminal, run this command:
bbedit -** /etc/my.cnf
Assuming you haven't already created a configuration file for MySQL, you should get a blank file. If the file isn't blank, copy and paste the contents in a reply.
Enter these lines into this file, save, and close it:
[mysqld]
socket=/tmp/mysql.sock
[client]
socket=/tmp/mysql.sock
The first line tells MySQL that the following lines are for the MySQL daemon. Then the
socket line tells it where to put the socket file. The next section is the client section and just tells the MySQL command line client application to look in the same place for the socket file.
3. Now, let's create a
launchd plist for MySQL. Back in Terminal, type this command:
bbedit -** /Library/LaunchDaemons/com.mysql.mysqld.plist
If you don't have an empty file, stop here and post the contents in a reply. If you do have an empty file, copy and paste this content into it, then save and close it"
<?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>Program</key>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>_mysql</string>
<key>WorkingDirectory</key>
<string>/usr/local/mysql</string>
</dict>
</plist>
4. Now, try to start MySQL. In Terminal, enter and run this command:
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
Use the Console app from your Utilities folder to look at the system log. You should see a message that it's started up. If not, post any errors that come up in either the Terminal app or the system log. If MySQl starts up successfully, you should just get the Terminal prompt back, and there should be a line in your system log a little like this:
com.mysql.mysqld[73594]: Starting mysqld daemon with databases from ...
where "..." will be the full path to your MySQL installation.
Re-run the command from step 1 to verify that it started. This time you should get two lines.
5. Once you've gotten the daemon started, you should be able to connect to it:
/usr/local/mysql/bin/mysql
If you haven't set any passwords, it should just connect, throw up a little information then stop at a prompt. Something like this:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 110
Server version: 5.0.67 MySQL Community Server (GPL)
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql>
Just type "
exit" and hit the enter key to leave for now. If You don't get that prompt, post any errors you get from the Terminal app.
6. Set up PHP. First, let's make a backup of the current php.ini file in case you've already edited it"
sudo cp /etc/php.ini /etc/php.ini.backup-20100108
Now get a fresh copy of the default
php.ini file:
sudo /etc/php.ini.default /etc/php.ini
Now, let's edit it:
bbedit /etc/php.ini
First, search for
mysql.default_socket. In my file, it's at line 761 (turn on line numbers in BBEdit). Change that line so it looks like this:
mysql.default_socket = /tmp/mysql.sock
Now search for
mysqli.default_socket and change the line it's on (796 in my file) to:
mysqli.default_socket = /tmp/mysq.sock
Now, save and close this file. You should stop and restart Apache. Once you do that, PHP should be able to connect to MySQL.
To stop the MySQL daemon, just reverse the launchctl command from step 4:
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist
Be patient, that takes 20 seconds or so...
charlie