Start mysql as a daemon on OS X Mavericks on boot

I’ve been doing some work with WordPress and Joomla recently, which led to the need to have mysql up and running on my dev server; it’s a mac mini running OS X Mavericks Server.

I’d like the mysqld process to run as a daemon in the background after the server boots; that way I don’t have to log in and start the process after each server reboot.  I couldn’t find a recent, up-to-date faq for doing this, so I thought I would write what I did.

I’m a big fan of homebrew, so I used it to install mysql.

homebrew is a unix-style package manager for OS X; it’s awesome!

If you don’t have homebrew installed on your mac, you can get it by opening the terminal app and using this command:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Then to install mysql…

brew install mysql

Read the output of the above command carefully, as there are a few more steps that won’t be covered here today that are required to initialize and setup your new mysql database.

The homebrew mysql package comes with some info for automatically launching mysql on login. You can access the info with the following command:

brew info mysql

This is the last part of the output of the above command:

...
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start

Remember, I want to have mysql run as a daemon even when there is no user actively logged into the dev server…

This can easily be accomplished by copying the homebrew.mxcl.mysql.plist file that is provided with the homebrew mysql package to the /Library/LaunchDaemons/ folder and then making some edits to the file in it’s new location.

Here is the contents of the included plist file:

<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mysql/bin/mysqld_safe</string>
<string>--bind-address=127.0.0.1</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var</string>
</dict>
</plist>

There are a couple of issues that need to be addressed with the default plist file if you want to run mysql as a daemon.

  1. You’ll want to call the mysqld executable directly instead of invoking the mysqld_safe script.
  2. You need to provide the user account that you would like to have run the mysqld process.
  3. You need to provide the complete path to the WorkingDirectory; which on my system is /usr/local/var/mysql

Before getting started with any changes to the included plist file, make a copy in the /Library/LaunchDaemons/ folder:

sudo cp /usr/local/opt/mysql/homebrew.mxcl.mysql.plist /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

Then open your favorite unix text editor (vim in my case):

sudo vim /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

Then make the following edits…

To call mysqld directly edit the line:

<string>/usr/local/opt/mysql/bin/mysqld_safe</string>

and change it to:

<string>/usr/local/opt/mysql/bin/mysqld</string>

To add the user account that you would like to have run the mysqld process, add the following line under the <key>ProgramArguments</key> line:

<string>--user=mysqlusergoeshere</string>

where mysqlusergoeshere is the unix name of the account you want to run the mysql process.

After

<key>RunAtLoad</key>
<true/>

Add the following two lines:

<key>UserName</key>
<string>mysqlusergoeshere</string>

Make sure the path for your WorkingDirectory leads to folder where your mysql data is located; in my case this was /usr/local/var/mysql :

<key>WorkingDirectory</key>
<string>/usr/local/var/mysql</string>

Here is the contents of the complete plist file with all the necessary modifications:

<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mysql/bin/mysqld</string>
<string>--bind-address=127.0.0.1</string>
<string>--user=mysqlusergoeshere</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>mysqlusergoeshere</string>
<key>WorkingDirectory</key>
<string>/usr/local/var/mysql</string>
</dict>
</plist>

Once you have all the changes made to the plist file, you’ll want to change ownership and permissions of the file so that it will work with the launchctl process.

If it isn’t already, change the owner to root and the group to wheel.

sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

Set the appropriate permission by changing the file mode to 644:

sudo chmod 644 /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

The last step is to load the plist with launchctl:

sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

mysqld should load immediately after this last command is run. It should also now load each time the system boots.

If you make changes to the plist file and need to reload it with launchctl, make sure you first unload the file:

sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

I hope this guide helps anyone out who would like to have their homebrew mysql run as a daemon on OS X Mavericks.

Apple Training Site Still Down

Update (8/8/2011): The Apple Training site has been back up for a couple of days. They are now offering the following certifications:

  • Apple Certified Associate: Mac Integration 10.7
  • Apple Certified Support Professional 10.7
  • Apple Certified Technical Coordinator 10.7

It appears that they have either discontinued or have not yet updated the Apple Certified System Administrator (ACSA) certification.

Training, course books, and certification for OS X Lion will be available later this fall.

–original post–

I’ve read that there are some pretty big changes in the works for Apple’s certification exams and training. I’m planning on taking some of the certifications, and have been checking training.apple.com every couple of days since OS X Lion was released.

Screen shot 2011-08-01 at 3.53.47 PM

It has surprised me that the site is still down!

Seems like a pretty big oversight to not have your training program ready to go with the launch of your new OS. Makes me wonder what Apple has in store for us?

OS X Lion Drops Rosetta and PowerPC Architecture Support For Intel Macs

Anyone who still uses any applications that were written for the PowerPC architecture should know that with the release of OS X v10.7 Lion, Apple has officially dropped Rosetta and support for older apps written for PowerPC.

What does this mean?

Your old PowerPC apps will not run on OS X Lion.

Is there a way to add Rosetta to OS X Lion?

No.

What can you do?

Helpful hint! Before upgrading, use the Finder’s Get Info feature to find out if any of your apps require Rosetta.

Apps that are written for the PowerPC architecture and require Rosetta to run on an Intel Mac will say:

Kind: Application(PowerPC)

PowerPC App

Apps that don’t require Rosetta will either say:

Kind: Application (Intel)
Kind: Application (Universal)

If you have PowerPC architecture apps, check to see if new, updated, Intel or Universal versions of your apps are available from the software developer.

If not, see if there is an alternative app that will substitute for your outdated PowerPC app.

Alternatively, if your app is mission critical and/or you have an extra Mac laying around, you can choose to keep OS X Leopard (v10.5) or Snow Leopard (v10.6) running on at least one Mac.

Then…

If you’re really itching to try OS X Lion, purchase one of the fantastic new MacBook Airs!

Mac OS X v10.7 Lion and Lion Server Review

There is an excellent review of Apple’s latest OS offerings, OS X Lion and OS X Lion Server on www.thetechscoop.net. The review is fairly comprehensive, hits most of the new features, and is relatively unbiased.

You can read the review here: http://www.thetechscoop.net/2011/07/20/mac-osx-10-lion-complete-review/

Although I have not downloaded and installed OS X Lion or Lion Server, from what I have read, it appears that the Server version is improved in some areas. However, the interface is significantly dumbed down and stripped down to make server administration easier for non-admins.

I mentioned in an earlier post that several key components have been removed, such as, MySQL and Tomcat. It also appears that many of the advanced server controls have either been eliminated from the GUI, or completely eliminated altogether.

These changes are great for server novices who want to try their hat at server admin.

However, I don’t think that this will bode well with many server admins in enterprise and research environments with complicated OS X Server deployments. I think many will choose not to upgrade.

I understand that Apple is going after with masses to capitalize on the overwhelming popularity of iOS. They are building iOS features into the core OS and are bringing server administration within the reaches of the common user.

I just don’t understand why they would choose to eliminate or severely hamstring many of the advanced server controls for more experienced admins. There is no reason that you can’t have both interfaces; Server made easy and Server on steroids. It seems that now we’ll have to hack at the command line more often to maintain the more advanced functionality of OS X Server.

This move along with the recent overhaul of Final Cut Pro X, seems to suggest that Apple has lost touch with it’s core devoted user base, that has historically helped sustain their market share in key markets (creative pros, science, academics) for so many years.

It appears that the mass-consumer market is now driving OS feature development. I can understand that for the core OS, but why for the Server version and Pro Apps?

Apple, please don’t try to turn my Mac into an iPhone, I already have one of those…

Some Significant changes under the hood in OS X v10.7 Lion Server

For anyone considering upgrading to Lion Server, check out this pdf from Apple titled, “Lion Server Upgrading and Migrating.” There are some significant changes under the hood to some of the core features included in Snow Leopard Server.

http://images.apple.com/macosx/server/docs/Upgrading_and_Migrating_v10.7.pdf

Check out page 5, “What’s new in Lion Server.”

Lion Server has major changes in several key areas:

  • Lateral Migrations: The migration of Lion Server to Lion Server is supported.
  • Server app Services are administrated by the new Server app.
  • PostgreSQL: MySQL is replaced with PostgreSQL.
  • Tomcat: Support for Tomcat is removed from Lion Server.
  • Axis: Support for Axis is removed from Lion Server.
  • Mobile Access: Support for Mobile Access is removed from Lion Server.
  • Print service: Print service is replaced with CUPS.
  • QuickTime Streaming Server (QTSS): Support for QTSS is removed from Lion Server.

As with any server upgrade or migration, make sure there isn’t any mission critical service(s) that will be broken or missing by migrating to Lion Server.

The replacement of MySQL with PostgreSQL and the removal of Tomcat will probably affect a lot of folks.