brew install mysql on mac os el capitan

william cage picture william cage · Dec 17, 2015 · Viewed 13.5k times · Source

I'm trying to install mysql on MAC OS version 10.11.2 by following the methods in this link,

The following command has been successfully executed,

brew install mysql

but when I type the following command,

mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

I get the following error:

mysql_install_db: [ERROR] unknown variable 'tmpdir=/tmp'
2015-12-17 17:35:54 [ERROR]   Unrecognized options

Please help. Thanks in advance.

Answer

Luke Murray picture Luke Murray · Jul 31, 2016

All credit goes to coder wall

Remove MySQL completely

  1. ps -ax | grep mysql stop and kill any MySQL processes
  2. brew remove mysql
  3. brew cleanup
  4. sudo rm /usr/local/mysql
  5. sudo rm -rf /usr/local/var/mysql
  6. sudo rm -rf /usr/local/mysql*
  7. sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  8. sudo rm -rf /Library/StartupItems/MySQLCOM
  9. sudo rm -rf /Library/PreferencePanes/My*
  10. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  11. edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
  12. rm -rf ~/Library/PreferencePanes/My*
  13. sudo rm -rf /Library/Receipts/mysql*
  14. sudo rm -rf /Library/Receipts/MySQL*
  15. sudo rm -rf /private/var/db/receipts/*mysql*
  16. edit ~/.bash_profile and remove any aliases for mysql or mysqlAdmin
  17. restart your computer just to ensure any MySQL processes are killed try to run mysql, it shouldn't work

Reinstall MySQL with Homebrew

  1. brew doctor
  2. brew update
  3. brew install mysql
  4. unset TMPDIR
  5. mysqld -initialize --log-error-verbosity --user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
  6. mysql.server start
  7. brew services start mysql