How I start MySQL, in 3 easy listings. (note the user/group used is named _mysql)
in /etc/rc.local:
Code:
# launch the MySQL database server
if [ -x /usr/local/bin/mysqld_safe -a -x /etc/rc.mysql ]; then
/etc/rc.mysql
fi
echo '.'
in /etc/rc.mysql:
Code:
#!/bin/sh
#
# A simple script to launch mysqld with the proper login privileges
#
su -c _mysql root -c '/usr/local/bin/mysqld_safe >/dev/null 2>&1 &'
echo -n ' mysql'
in /etc/login.conf:
Code:
#
# This class is used when running MySQL from /etc/rc.local
# XXX: It will *N_O_T* be used when starting/stopping mysqld manually!!
#
_mysql:\
:ignorenologin:\
:datasize=infinity:\
:maxproc=infinity:\
:openfiles=3580:\ # I've set this to sysctl::kern.maxfiles
:stacksize-cur=8M:\
:localcipher=blowfish,8:\
:tc=daemon:
note: set it to need, see login.conf in OpenBSD manual for details.
The rc.mysql script is used so that if I have to stop my database for some reason, I can restart it with the correct credentials without having to check rc.local for the commands.
As Carpetsmoker, jggimi, and ocicat have pointed out - do be sure to read the documentation while you're at it, it helps.