Next, double-click on the MySQL.prefPane item and install it.
This adds a MySQLconfiguration entry to the System Preferences from the System Preferences window,
you can manually start and stop the MySQL server, and also select whether you want the server to be automatically started each time the system boots.
Finally, if you want the MySQL server to be started and stopped automatically each time the
computer is started or stopped, double-click on the MySQLStartupItem.pkg item and install this too.
Configuring the installed serverFor security reasons, it’s a good idea to have the MySQL server run under
its own username and group, rather than under the superuser account. If something goes wrong with the server, or an attacker gains control of the server, the damage will be restricted to the MySQL user rather than the whole system. Mac OS X comes with a mysql user and group already defined. You can check this using the
graphical NetInfo Manager tool, or from the shell prompt.
To check using the NetInfo Manager, double-click on the NetInfo Manager icon in the
Utilities folder
under the Applications group, as shown in Figure 2-18. Then, select
“groups” and scroll down to make sure that there is an entry for the mysql group, as shown in Figure 2-19. Similarly, you can select users and scroll down to see that there is an entry for the mysql user there too.
You can instead check these settings from the shell prompt. To do this, open a terminal window and use the grep command to search for the word mysql in the system’s list of users (the
/etc/passwd file) and groups (the
/etc/group file
grep mysql /etc/passwd /etc/group/etc/passwd:mysql:*:74:74:MySQL Server:/var/empty:/usr/bin/false
/etc/group:mysql:*:74:
Figure 2-17. The contents of the MySQL AB Mac OS X installer package62 | Chapter 2:Installing MySQL You should see two lines similar to the ones above.
If, for some reason, the mysql user and group aren’t configured on your system, you have to create them. You can add them in the NetInfo Manager by clicking on the lock icon at the bottom of the screen and selecting the Add entry from the Edit menu. However, it’s probably faster to perform these steps from the command line.
First,
create the user mysql(note that the first forward slash symbol (
/
) stands by itself on the line
sudo niutil -create / /users/mysqland assign invalid (and therefore relatively secure) values for the home directory and login shell
sudo niutil -createprop / /users/mysql home /var/empty$
sudo niutil -createprop / /users/mysql shell /usr/bin/falseNext,
create the group mysql:
$
sudo niutil -create / /groups/mysqlOnce you’ve done this, define a Group ID number (
gid
) for the mysql group and a User
ID number (
uid
) for the mysql user. The Mac OS X default value for both these IDs is you can choose this or any other value—for example, 674—that’s not already allocated to a user or group. Let’s use 74 in our example, and assign this value to the mysql group and user:
Figure 2-18. Starting the Mac OS X NetInfo ManagerShare with your friends: