Wednesday, March 23, 2011

My Oh My! This is How MySQL Daemon is Done in OpenBSD

If you were to setup a secure Unix-like server, don't walk, run for OpenBSD, probably the most secure operating system on the planet. On databases, I frankly have personal and professional bias for PostgreSQL, but for the benefit of the uninformed masses, most prefer MySQL.

Putting two and two together, one way or another, being a systems administrator, you will one day need to setup an OpenBSD to house a MySQL server. As of this writing, OpenBSD is version 4.8 going to 4.9.

In this post we won't discuss how to install OpenBSD, you'll find a more comprehensive information on that from here. As for the installation of MySQL as a package, you'll find the guide on that here. What we're going to tackle today is the elusive way to configure MySQL server as a daemon on OpenBSD startup so you don't have to worry whether it will restart when your server reboots.

One of the best features on OpenBSD, aside from being secure, is it's extensive documentation on what can and can't be done with it. Unfortunately, setting up the daemon for MySQL isn't included and we have to weed through the Internet for that little information.

It turns out to be so simple, just go open /etc/rc.local with your preferred text editor (Unix users aiming for machismo dig vi) and type the following after the marker indicating where to add local startup actions, and add these lines of code:

if [ -x /usr/local/bin/mysqld_safe ] ; then
   echo -n 'mysqld'
   /usr/local/bin/mysqld_safe &

That's all there is to it (could make you exclaim "My oh my!"), and it made me wonder why many resources online make it so complicated. Hope this helps someone and save them the time and trouble.

No comments:

Post a Comment