2
2.7. Installing MySQL on Mac OS X
4
MySQL for Mac OS X is available in a number of different forms:
6
* Native Package Installer format, which uses the native Mac OS
7
X installer to walk you through the installation of MySQL. For
8
more information, see Section 2.7.1, "Installing MySQL Using
9
the Installation Package." You can use the package installer
10
with Mac OS X 10.3 and later, and available for both PowerPC
11
and Intel architectures, and both 32-bit and 64-bit
12
architectures. There is no Universal Binary available using
13
the package installation method. The user you use to perform
14
the installation must have administrator privileges.
16
* Tar package format, which uses a file packaged using the Unix
17
tar and gzip commands. To use this method, you will need to
18
open a Terminal window. You do not need administrator
19
privileges using this method, as you can install the MySQL
20
server anywhere using this method. For more information on
21
using this method, you can use the generic instructions for
22
using a tarball, Section 2.2, "Installing MySQL from Generic
23
Binaries on Unix/Linux."You can use the package installer with
24
Mac OS X 10.3 and later, and available for both PowerPC and
25
Intel architectures, and both 32-bit and 64-bit architectures.
26
A Universal Binary, incorporating both Power PC and Intel
27
architectures and 32-bit and 64-bit binaries is available.
28
In addition to the core installation, the Package Installer
29
also includes Section 2.7.2, "Installing the MySQL Startup
30
Item" and Section 2.7.3, "Installing and Using the MySQL
31
Preference Pane," both of which simplify the management of
34
* Mac OS X server includes a version of MySQL as standard. If
35
you want to use a more recent version than that supplied with
36
the Mac OS X server release, you can make use of the package
37
or tar formats. For more information on using the MySQL
38
bundled with Mac OS X, see Section 2.7.4, "Using MySQL on Mac
41
For additional information on using MySQL on Mac OS X, see Section
42
2.7.5, "MySQL Installation on Mac OS X Notes."
44
2.7.1. Installing MySQL Using the Installation Package
46
You can install MySQL on Mac OS X 10.3.x ("Panther") or newer
47
using a Mac OS X binary package in PKG format instead of the
48
binary tarball distribution. Please note that older versions of
49
Mac OS X (for example, 10.1.x or 10.2.x) are not supported by this
52
The package is located inside a disk image (.dmg) file that you
53
first need to mount by double-clicking its icon in the Finder. It
54
should then mount the image and display its contents.
58
Before proceeding with the installation, be sure to shut down all
59
running MySQL server instances by either using the MySQL Manager
60
Application (on Mac OS X Server) or via mysqladmin shutdown on the
63
When installing from the package version, you should also install
64
the MySQL Preference Pane, which will allow you to control the
65
startup and execution of your MySQL server from System
66
Preferences. For more information, see Section 2.7.3, "Installing
67
and Using the MySQL Preference Pane."
69
When installing using the package installer, the files are
70
installed into a directory within /usr/local matching the name of
71
the installation version and platform. For example, the installer
72
file mysql-5.1.39-osx10.5-x86_64.pkg installs MySQL into
73
/usr/local/mysql-5.1.39-osx10.5-x86_64 . The installation layout
74
of the directory is as shown in the following table:
75
Directory Contents of Directory
76
bin Client programs and the mysqld server
77
data Log files, databases
78
docs Manual in Info format
79
include Include (header) files
82
mysql-test MySQL test suite
83
scripts Contains the mysql_install_db script
84
share/mysql Error message files
86
support-files Scripts and sample configuration files
87
/tmp/mysql.sock The location of the MySQL Unix socket
89
During the package installer process, a symbolic link from
90
/usr/local/mysql to the version/platform specific directory
91
created during installation will be created automatically.
93
1. Download and open the MySQL package installer, which is
94
provided on a disk image (.dmg). Double-click to open the disk
95
image, which includes the main MySQL installation package, the
96
MySQLStartupItem.pkg installation package, and the
99
2. Double-click on the MySQL installer package. It will be named
100
according to the version of MySQL you have downloaded. For
101
example, if you have downloaded MySQL 5.1.39, double-click
102
mysql-5.1.39-osx10.5-x86.pkg.
104
3. You will be presented with the openin installer dialog. Click
105
Continue to begihn installation.
106
MySQL Package Installer: Step 1
108
4. A copy of the installation instructions and other important
109
information relevant to this installation are display. Click
112
5. If you have downloaded the community version of MySQL, you
113
will be shown a copy of the relevent GNU General Public
114
License. Click Continue .
116
6. Select the drive you want to use to install the MySQL Startup
117
Item. The drive must have a valid, bootable, Mac OS X
118
operating system installed. Click Continue.
119
MySQL Package Installer: Step 4
121
7. You will be asked to confirm the details of the installation,
122
including the space required for the installation. To change
123
the drive on which the startup item is installed you can click
124
either Go Back or Change Install Location.... To install the
125
startup item, click Install.
127
8. Once the installation has been completed successfully, you
128
will be given an Install Succeeded message.
130
Once you have completed the basic installation, you must complete
131
the post-installation steps as specifed in Section 2.13,
132
"Post-Installation Setup and Testing."
134
For convenience, you may also want to install the Section 2.7.2,
135
"Installing the MySQL Startup Item" and Section 2.7.3, "Installing
136
and Using the MySQL Preference Pane."
138
2.7.2. Installing the MySQL Startup Item
140
The MySQL Installation Package includes a startup item that can be
141
used to automatically startup and shutdown MySQL during boot.
143
To install the MySQL Startup Item:
145
1. Download and open the MySQL package installer, which is
146
provided on a disk image (.dmg). Double-click to open the disk
147
image, which includes the main MySQL installation package, the
148
MySQLStartupItem.pkg installation package, and the
151
2. Double-click on the MySQLStartItem.pkg file to start the
152
installation process.
154
3. You will be presented with the Install MySQL Startup Item
156
MySQL Startup Item Installer: Step 1
157
Click Continue to continue the installation process.
159
4. A copy of the installation instructions and other important
160
information relevant to this installation are display. Click
163
5. Select the drive you want to use to install the MySQL Startup
164
Item. The drive must have a valid, bootable, Mac OS X
165
operating system installed. Click Continue.
166
MySQL Startup Item Installer: Step 3
168
6. You will be asked to confirm the details of the installation.
169
To change the drive on which the startup item is installed you
170
can click either Go Back or Change Install Location.... To
171
install the startup item, click Install.
173
7. Once the installation has been completed successfully, you
174
will be given an Install Succeeded message.
175
MySQL Startup Item Installer: Step 5
177
The Startup Item for MySQL is installed into
178
/Library/StartupItems/MySQLCOM. The Startup Item installation adds
179
a variable MYSQLCOM=-YES- to the system configuration file
180
/etc/hostconfig. If you want to disable the automatic startup of
181
MySQL, simply change this variable to MYSQLCOM=-NO-.
183
After the installation, you can start up MySQL by running the
184
following commands in a terminal window. You must have
185
administrator privileges to perform this task.
187
If you have installed the Startup Item, use this command to start
189
shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
191
You may be prompted for your password to complete the startup.
193
If you have installed the Startup Item, use this command to stop
195
shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
197
You may be prompted for your password to complete the shutdown.
199
2.7.3. Installing and Using the MySQL Preference Pane
201
The MySQL Package installer disk image also includes a custom
202
MySQL Preference Pane that enables you to start, stop and control
203
automated startup during boot of your MySQL installation.
205
To install the MySQL Preference Pane:
207
1. Download and open the MySQL package installer package, which
208
is provided on a disk image (.dmg). Double-click to open the
209
disk image, which includes the main MySQL installation
210
package, the MySQLStartupItem.pkg installation package, and
213
2. Double click on MySQL.prefPane. The MySQL System Preferences
216
3. If this is the first time you have installed the preference
217
pane, you will be asked to confirm installation and whether
218
you want to install the preference pane for all users, or only
219
the current user. To install the preference pane for all users
220
you will need administrator privileges. If necessary, you will
221
be prompted for the username and password for a user with
222
administrator privileges.
224
4. If you already have the MySQL Preference Pane installed, you
225
will be asked to confirm whether you want to overwrite the
226
existing MySQL Preference Pane.
230
The MySQL Preference Pane only starts and stops MySQL installation
231
installed from the MySQL package installation that have been
232
installed in the default location.
234
Once the MySQL Preference Pane has been installed, you can control
235
your MySQL server instance using the preference pane. To use the
236
preference pane, open the System Preferences... from the Apple
237
menu. Select the MySQL preference pane by clicking on the MySQL
238
logo within the Other section of the preference panes list.
239
MySQL Preference Pane
241
The MySQL Preference Pane shows the current status of the MySQL
242
server, showing stopped (in red) if the server is not running and
243
running (in green) if the server has already been started. The
244
preference pane will also show the current setting for whether the
245
MySQL server has been set to start up automatically.
247
* To start MySQL using the preference pane:
248
Click Start MySQL Server. You may be prompted for the username
249
and password of a user with administrator privileges to start
252
* To stop MySQL using the preference pane:
253
Click Stop MySQL Server. You may be prompted for the username
254
and password of a user with administrator privileges to
255
shutdown the MySQL server.
257
* To automatically start the MySQL server when the system boots:
258
Check the checkbox next to Automatically Start MySQL Server on
261
* To disable the automatic starting of the MySQL server when the
263
Uncheck the checkbox next to Automatically Start MySQL Server
266
You can close the System Preferences... once you have completed
269
2.7.4. Using MySQL on Mac OS X Server
271
If you are running Mac OS X Server, a version of MySQL should
272
already be installed. The following table shows the versions of
273
MySQL that ship with Mac OS X Server versions.
274
Mac OS X Server Version MySQL Version
276
10.2.3-10.2.6 3.23.53
283
The installation layout of MySQL on Mac OS X Server is as shown in
285
Directory Contents of Directory
286
/usr/bin Client programs
287
/var/mysql Log files, databases
288
/usr/libexec The mysqld server
289
/usr/share/man Unix manual pages
290
/usr/share/mysql/mysql-test MySQL test suite
291
/usr/share/mysql Contains the mysql_install_db script
292
/var/mysql/mysql.sock The location of the MySQL Unix socket
296
The MySQL server bundled with Mac OS X Server does not include the
297
MySQL client libraries and header files required if you want to
298
access and use MySQL from a third-party driver, such as Perl DBI
299
or PHP. For more information on obtaining and installing MySQL
300
libraries, see Mac OS X Server version 10.5: MySQL libraries
301
available for download (http://support.apple.com/kb/TA25017).
302
Alternatively, you can ignore the bundled MySQL server and install
303
MySQL from the package or tarball installation.
305
For more information on managing the bundled MySQL instance in Mac
306
OS X Server 10.5, see Mac OS X Server: Web Technologies
307
Administration For Version 10.5 Leopard
308
(http://images.apple.com/server/macosx/docs/Web_Technologies_Admin
309
_v10.5.pdf). For more information on managing the bundled MySQL
310
instance in Mac OS X Server 10.6, see Mac OS X Server: Web
311
Technologies Administration Version 10.6 Snow Leopard
312
(http://manuals.info.apple.com/en_US/WebTech_v10.6.pdf).
314
2.7.5. MySQL Installation on Mac OS X Notes
316
You should keep the following issues and notes in mind:
318
* The default location for the MySQL Unix socket is different on
319
Mac OS X and Mac OS X Server depending on the installation
320
type you chose. The default locations by installation are as
323
Package Installer from MySQL /tmp/mysql.sock
324
Tarball from MySQL /tmp/mysql.sock
325
MySQL Bundled with Mac OS X Server /var/mysql/mysql.sock
326
To prevent issues, you should either change the configuration
327
of the socket used within your application (for example,
328
changing php.ini), or you should configure the socket location
329
using a MySQL configuration file and the socket option. For
330
more information, see Section 5.1.2, "Server Command Options."
332
* You may need (or want) to create a specific mysql user to own
333
the MySQL directory and data. On Mac OS X 10.4 and lower you
334
can do this by using the Netinfo Manager application, located
335
within the Utilities folder within the Applications folder. On
336
Mac OS X 10.5 and later you can do this through the Directory
337
Utility. From Mac OS X 10.5 and later (including Mac OS X
338
Server 10.5) the mysql should already exist. For use in single
339
user mode, an entry for _mysql (note the underscore prefix)
340
should already exist within the system /etc/passwd file.
342
* Due to a bug in the Mac OS X package installer, you may see
343
this error message in the destination disk selection dialog:
344
You cannot install this software on this disk. (null)
345
If this error occurs, simply click the Go Back button once to
346
return to the previous screen. Then click Continue to advance
347
to the destination disk selection again, and you should be
348
able to choose the destination disk correctly. We have
349
reported this bug to Apple and it is investigating this
352
* Because the MySQL package installer installs the MySQL
353
contents into a version and platform specific directory, you
354
can use this to upgrade and migrate your database between
355
versions. You will need to either copy the data directory from
356
the old version to the new version, or alternatively specify
357
an alternative datadir value to set location of the data
360
* You might want to add aliases to your shell's resource file to
361
make it easier to access commonly used programs such as mysql
362
and mysqladmin from the command line. The syntax for bash is:
363
alias mysql=/usr/local/mysql/bin/mysql
364
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
366
alias mysql /usr/local/mysql/bin/mysql
367
alias mysqladmin /usr/local/mysql/bin/mysqladmin
368
Even better, add /usr/local/mysql/bin to your PATH environment
369
variable. You can do this by modifying the appropriate startup
370
file for your shell. For more information, see Section 4.2.1,
371
"Invoking MySQL Programs."
373
* After you have copied over the MySQL database files from the
374
previous installation and have successfully started the new
375
server, you should consider removing the old installation
376
files to save disk space. Additionally, you should also remove
377
older versions of the Package Receipt directories located in
378
/Library/Receipts/mysql-VERSION.pkg.