Posted on Mar 27, 2008 in
Mac OS X
Mac OS X 10.5 Server comes with the MySQL pre-installed. However, the database server doesn’t ship with the client version of OS X 10.5 Leopard, which most of us Mac users run. Here are the notes I took, putting MySQL 5.1 on a 2 GHz Intel Core Duo based iMac (none 64 bit) running OS X 10.5.2 (Client)
Installing MySQL 5.1 On OS X 10.5 (Leopard) Client
Download the pre-compiled module package in form of a diskimage (dmg), available at http://dev.mysql.com/downloads/mysql/ For the 2 GHz Intel Core Duo based iMac, I downloaded the 32-bit version mysql-5.1.23-rc-osx10.5-x86.dmg. Newer Macs, featuring a Core-2-Duo processor should work best with the 64-bit version.
Open (double-click) the dmg file, followed by running (double-click) the mysql-5.1.23-rc-osx10.5-x86.pkg package installer.
The package installer will install the mysql into /usr/local/mysql-5.1.23-rc-osx10.5-x86 and also create this shortcut /usr/local/mysql/
Installing the Preferences Pane won’t do us any good, it does not work anymore with OS X 10.5. Instead, the launchd mysql.plist file needs to be created and stored in /Library/LaunchDaemons/ and also given ownership to root:
sudo chown root:wheel /Library/LaunchDaemons/mysql.plist
mysql.plist
<?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>GroupName</key>
<string>mysql</string>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<key>UserName</key>
<string>mysql</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
This command line can now be used to start MySQL:
sudo launchctl load /Library/LaunchDaemons/mysql.plist
and to stop it:
sudo launchctl stop mysql
sudo launchctl unload /Library/LaunchDaemons/mysql.plist
From now on, the MySQL Server will be started at boot time and (re-)starting should not be necessary anymore. Here, a check was done with the ActivityMonior, showing MySQL running:

Entering this command line after starting the server, /usr/local/mysql/bin/mysql should produce an output something like this:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.23-rc MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
.profile
Adding /usr/local/mysql/bin to the ~/.profile provides easier access to all of MySQL’s tools.
E.g. use pico ~/.profile to insert this line into your shell profile:
PATH=${PATH}:/usr/local/mysql/bin
Setting root user’s password and creating more users
Since the MySQL’s root password is not set by default, this is one of the 1st things that need to be done like so:
mysqladmin -u root password myPassWord
Instead of using the command line, more users can now be added using a GUI tool like DbVisualizer

Using MySQL with PHP
PHP on OS X 10.5 is looking for mysql.sock at /var/mysq/mysql.sock. However, the mysql installer puts it at /tmp/mysql.sock. Creating the directory and a symlink, seem to be the best way to work around:
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Read More
Social Links