Skip to content

Instantly share code, notes, and snippets.

@qjawe
Forked from subfuzion/mysql-autostart-osx.md
Created February 22, 2017 06:33
Show Gist options
  • Save qjawe/84542113c2c501fb52f6336a64b3509a to your computer and use it in GitHub Desktop.
Save qjawe/84542113c2c501fb52f6336a64b3509a to your computer and use it in GitHub Desktop.
mysql auto start on OS X

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