Skip to content

Instantly share code, notes, and snippets.

@vpilot
Last active August 29, 2015 14:10
Show Gist options
  • Save vpilot/12e50b3f647d467f6ca3 to your computer and use it in GitHub Desktop.
Save vpilot/12e50b3f647d467f6ca3 to your computer and use it in GitHub Desktop.
# Install mysql
brew install mysql
# pin the version so you don't override it accidentally with upgrate
brew pin mysql
# Copy launch agent into place
mkdir -p ~/Library/LaunchAgents && cp /usr/local/Cellar/mysql/<version>/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
# Edit launch agent and set both keepalive and runatload at startup to false
vi ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# Inject launch agent
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# Set up databases to run as your user account
unset TMPDIR && mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
# Start mysql
mysql.server start
# Secure mysql
/usr/local/Cellar/mysql/<version>/bin/mysql_secure_installation
# OSX thinks socket should be in /var/mysql/mysql.sock but mysql creates socket in /tmp/mysql.sock
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment