Creating a MySQL StartupItem
With the Finder, make a new Folder in /Library/StartupItems and name it MySQL. In the new MySQL folder we need to create a couple of files. You can use TextEdit or any other text editor for this. If you use TextEdit, make sure you only use .txt formatting, not .rtf. (Format Menu>Make Plain Text)
The first file is the unix shell script that will be launched at startup time. Copy and paste these lines into TextEdit:
# Start MySQL database server
ConsoleMessage “Starting MySQL Database Server”
sudo /usr/local/mysql/bin/mysqld_safe –user=mysql &
This is the same command we use to start MySQL when we finished compiling and installing it. We have just put it into a unix shell script that we will run whenever the system is booted. Save this file in the MySQL folder and name it MySQL. TextEdit will append a .txt extension to the filename. With the Finder, rename it to only MySQL.
With the Terminal issue the following command:
chmod 755 /Library/StartupItems/MySQL/MySQL
This makes the file executable. We also need some system information for the shell script. Copy and paste the following into a new TextEdit document:
Description = "MySQL Database Server";
Provides = ("MySQL");
Requires = ("Resolver");
OrderPreference = "Last";
start = "Starting MySQL Database Server";
stop = "Stopping MySQL Database Server";
Save this file in the MySQL folder and name it StartupParameters.plist. Don’t let TextEdit append a .txt extension to the name.
Now, whenever you reboot or your system is started, the StartupItem will be executed and your MySQL Database Server will be launched. Verify this by rebooting your computer, login to your account, launch the Terminal and issue the following command:
ps aucx | grep 'mysql'
You should see a line giving the process ID information for the running MySQL server daemon. Now that we have upgraded the Apache Web Server and installed a MySQL Database Server, we will tackle installing the PHP web scripting language to complete our set of tools for using a Content Management System.