OSX Launching mysql at startup in Yosemite

This assumes that you installed mysql using homebrew (ie. brew install mysql)


ln -sfv /usr/local/opt/mysql/*.plist /Library/LaunchDaemons

# to manualy start the service
# sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

Gotta make sure it's got the right permissions:
sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/homebrew.mxcl.mysql.plist


Contents of the homebrew.mxcl.mysql.plist file:


  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple
  3 <plist version="1.0">
  4 <dict>
  5   <key>KeepAlive</key>
  6   <true/>
  7   <key>Label</key>
  8   <string>homebrew.mxcl.mysql</string>
  9   <key>ProgramArguments</key>
 10   <array>
 11     <string>/usr/local/opt/mysql/bin/mysqld_safe</string>
 12     <string>--user=root</string>
 13     <string>--socket=<socket filepath></string>
 14     <string>--pid-file=<pid filepath></string>
 15     <string>--bind-address=127.0.0.1</string>
 16     <string>--datadir=<data directory></string>
 17   </array>
 18   <key>RunAtLoad</key>
 19   <true/>
 20   <key>WorkingDirectory</key>
 21   <string>/usr/local/var</string>
 22 </dict>
 23 </plist>

No comments: