Skip to content

Instantly share code, notes, and snippets.

@JimLiu
Forked from subfuzion/mysql-autostart-osx.md
Last active August 29, 2015 14:24
Show Gist options
  • Save JimLiu/72d26174aac2c5453ee9 to your computer and use it in GitHub Desktop.
Save JimLiu/72d26174aac2c5453ee9 to your computer and use it in GitHub Desktop.

Install with Homebrew

brew install mysql

Set up launchctl to auto start mysql

$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents

/usr/local/opt/mysql/ is a symlink to /usr/local/Cellar/mysql/x.y.z (e.g., 5.6.16)

You can use launchctl to start and stop mysql

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

You can also more conveniently use brew to start, stop, and verify service status

$ brew services list | grep mysql
$ brew services start mysql
$ brew services stop mysql

Notes

The mysql configuration is stored at /usr/local/opt/mysql/my.conf.

For more about launchctl see:

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/launchctl.1.html#//apple_ref/doc/man/1/launchctl

http://launchd.info/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment