Skip to content

Instantly share code, notes, and snippets.

@m4tthumphrey
Created December 19, 2012 21:28
Show Gist options
  • Save m4tthumphrey/4340697 to your computer and use it in GitHub Desktop.
Save m4tthumphrey/4340697 to your computer and use it in GitHub Desktop.
macbook:~ matt$ brew install mysql \
> && sudo mkdir -p /Library/LaunchAgents \
> && sudo cp LaunchAgents/homebrew.mxcl.mysql.plist /Library/LaunchAgents/ \
> && sudo launchctl load /Library/LaunchAgents/homebrew.mxcl.mysql.plist \
> && sudo mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Installing mysql dependency: cmake
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/cmake-2.8.10.1.mountainlion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring cmake-2.8.10.1.mountainlion.bottle.tar.gz
/usr/local/Cellar/cmake/2.8.10.1: 683 files, 32M
==> Installing mysql
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/mysql-5.5.28.mountainlion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mysql-5.5.28.mountainlion.bottle.tar.gz
==> Caveats
Set up databases to run AS YOUR USER ACCOUNT with:
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
To set up base tables in another folder, or use a different user to run
mysqld, view the help for mysqld_install_db:
mysql_install_db --help
and view the MySQL documentation:
* http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
* http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html
To run as, for instance, user "mysql", you may need to `sudo`:
sudo mysql_install_db ...options...
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
mysql -uroot
==> Caveats
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
==> Summary
/usr/local/Cellar/mysql/5.5.28: 6386 files, 209M
Password:
cp: LaunchAgents/homebrew.mxcl.mysql.plist: No such file or directory
macbook:~ matt$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
macbook:~ matt$ sudo mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
macbook:~ matt$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
/Users/matt/Library/LaunchAgents/homebrew.mxcl.mysql.plist -> /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
macbook:~ matt$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
macbook:~ matt$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
macbook:~ matt$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment