Skip to content

Instantly share code, notes, and snippets.

@ihor
Last active July 13, 2018 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihor/3823371 to your computer and use it in GitHub Desktop.
Save ihor/3823371 to your computer and use it in GitHub Desktop.
/etc/init.d/mysql script for Homebrew installed MySQL
#!/bin/bash
DAEMON=/usr/local/bin/mysqld_safe
OPTS=--defaults-file=/usr/local/etc/mysql/my.cnf
NAME=mysql
DESC=mysql
test -x $DAEMON || exit 0
set -e
start()
{
$DAEMON $OPTS > /var/log/mysql/output.log 2>&1 &
return
}
stop()
{
kill `cat /usr/local/var/run/mysqld/mysqld.pid`
return
}
case "$1" in
start)
echo -n "Starting $DESC: "
start
echo "started."
;;
stop)
echo -n "Stopping $DESC: "
stop
echo "stopped."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
stop
sleep 1
start
echo "restarted."
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment