2.4. Installing MySQL on Mac OS X
MySQL for Mac OS X is available in a number of different forms:
* Native Package Installer format, which uses the native Mac OS
X installer to walk you through the installation of MySQL. For
more information, see Section 2.4.2, "Installing MySQL on Mac
OS X Using Native Packages." You can use the package installer
with Mac OS X 10.3 and later, and the package is available for
both PowerPC and Intel architectures, and 32-bit and 64-bit
architectures. There is no Universal Binary available using
the package installation method. The user you use to perform
the installation must have administrator privileges.
* Tar package format, which uses a file packaged using the Unix
tar and gzip commands. To use this method, you will need to
open a Terminal window. You do not need administrator
privileges using this method, as you can install the MySQL
server anywhere using this method. For more information on
using this method, you can use the generic instructions for
using a tarball, Section 2.2, "Installing MySQL from Generic
Binaries on Unix/Linux."You can use the package installer with
Mac OS X 10.3 and later, and available for both PowerPC and
Intel architectures, and both 32-bit and 64-bit architectures.
A Universal Binary, incorporating both Power PC and Intel
architectures and 32-bit and 64-bit binaries is available.
In addition to the core installation, the Package Installer
also includes Section 2.4.3, "Installing the MySQL Startup
Item" and Section 2.4.4, "Installing and Using the MySQL
Preference Pane," both of which simplify the management of
your installation.
* Mac OS X server includes a version of MySQL as standard. If
you want to use a more recent version than that supplied with
the Mac OS X server release, you can make use of the package
or tar formats. For more information on using the MySQL
bundled with Mac OS X, see Section 2.4.5, "Using the Bundled
MySQL on Mac OS X Server."
For additional information on using MySQL on Mac OS X, see Section
2.4.1, "General Notes on Installing MySQL on Mac OS X."
2.4.1. General Notes on Installing MySQL on Mac OS X
You should keep the following issues and notes in mind:
* The default location for the MySQL Unix socket is different on
Mac OS X and Mac OS X Server depending on the installation
type you chose. The following table shows the default
locations by installation type.
Table 2.4. MySQL Unix Socket Locations on Mac OS X by
Installation Type
Installation Type Socket Location
Package Installer from MySQL /tmp/mysql.sock
Tarball from MySQL /tmp/mysql.sock
MySQL Bundled with Mac OS X Server /var/mysql/mysql.sock
To prevent issues, you should either change the configuration
of the socket used within your application (for example,
changing php.ini), or you should configure the socket location
using a MySQL configuration file and the socket option. For
more information, see Section 5.1.3, "Server Command Options."
* You may need (or want) to create a specific mysql user to own
the MySQL directory and data. On Mac OS X 10.4 and lower you
can do this by using the Netinfo Manager application, located
within the Utilities folder within the Applications folder. On
Mac OS X 10.5 and later you can do this through the Directory
Utility. From Mac OS X 10.5 and later (including Mac OS X
Server 10.5) the mysql should already exist. For use in single
user mode, an entry for _mysql (note the underscore prefix)
should already exist within the system /etc/passwd file.
* Due to a bug in the Mac OS X package installer, you may see
this error message in the destination disk selection dialog:
You cannot install this software on this disk. (null)
If this error occurs, click the Go Back button once to return
to the previous screen. Then click Continue to advance to the
destination disk selection again, and you should be able to
choose the destination disk correctly. We have reported this
bug to Apple and it is investigating this problem.
* Because the MySQL package installer installs the MySQL
contents into a version and platform specific directory, you
can use this to upgrade and migrate your database between
versions. You will need to either copy the data directory from
the old version to the new version, or alternatively specify
an alternative datadir value to set location of the data
directory.
* You might want to add aliases to your shell's resource file to
make it easier to access commonly used programs such as mysql
and mysqladmin from the command line. The syntax for bash is:
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
For tcsh, use:
alias mysql /usr/local/mysql/bin/mysql
alias mysqladmin /usr/local/mysql/bin/mysqladmin
Even better, add /usr/local/mysql/bin to your PATH environment
variable. You can do this by modifying the appropriate startup
file for your shell. For more information, see Section 4.2.1,
"Invoking MySQL Programs."
* After you have copied over the MySQL database files from the
previous installation and have successfully started the new
server, you should consider removing the old installation
files to save disk space. Additionally, you should also remove
older versions of the Package Receipt directories located in
/Library/Receipts/mysql-VERSION.pkg.
2.4.2. Installing MySQL on Mac OS X Using Native Packages
You can install MySQL on Mac OS X 10.3.x ("Panther") or newer
using a Mac OS X binary package in PKG format instead of the
binary tarball distribution. Please note that older versions of
Mac OS X (for example, 10.1.x or 10.2.x) are not supported by this
package.
The package is located inside a disk image (.dmg) file that you
first need to mount by double-clicking its icon in the Finder. It
should then mount the image and display its contents.
Note
Before proceeding with the installation, be sure to stop all
running MySQL server instances by using either the MySQL Manager
Application (on Mac OS X Server) or mysqladmin shutdown on the
command line.
When installing from the package version, you should also install
the MySQL Preference Pane, which will enable you to control the
startup and execution of your MySQL server from System
Preferences. For more information, see Section 2.4.4, "Installing
and Using the MySQL Preference Pane."
When installing using the package installer, the files are
installed into a directory within /usr/local matching the name of
the installation version and platform. For example, the installer
file mysql-5.1.39-osx10.5-x86_64.pkg installs MySQL into
/usr/local/mysql-5.1.39-osx10.5-x86_64 . The following table shows
the layout of the installation directory.
Table 2.5. MySQL Installation Layout on Mac OS X
Directory Contents of Directory
bin Client programs and the mysqld server
data Log files, databases
docs Manual in Info format
include Include (header) files
lib Libraries
man Unix manual pages
mysql-test MySQL test suite
scripts mysql_install_db
share Miscellaneous support files, including error messages,
sample configuration files, SQL for database installation
sql-bench Benchmarks
support-files Scripts and sample configuration files
/tmp/mysql.sock Location of the MySQL Unix socket
During the package installer process, a symbolic link from
/usr/l