24

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.

william cage
  • 429
  • 1
  • 4
  • 18

3 Answers3

47

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
Luke Murray
  • 861
  • 8
  • 10
  • Thanks so much, worked for me. Some places have suggested that afterwards, to add MySQL to launchctl so it automatically launches at startup. Any idea how to do this? – TheJKFever Sep 01 '16 at 21:29
  • 2
    brew says this: To have launchd start mysql now and restart at login: brew services start mysql – Andy Sep 05 '16 at 20:19
  • for any other weary travelers, this worked when followed with the password setting steps described [here](http://stackoverflow.com/a/33332443/628699) – imjared Nov 08 '16 at 16:37
  • thank you for the feedback imjared, which step did you perform that after? i can edit my post to reflect the new information. – Luke Murray Nov 09 '16 at 00:19
  • sometimes brew will allow you to sudo prefix your command, such as. sudo brew services start mysql. This may help some of you who get failure while executing launchctl. – cgseller Apr 30 '17 at 17:43
22

Try running this, it worked for me. (Got it from the comments found here)

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

Posting here just in case anyone faced the same problem as me.

Her Lung Wong
  • 320
  • 3
  • 6
0

Based on this link: https://bugs.launchpad.net/mysql-sandbox/+bug/1396092 and this https://blog.omgmog.net/post/installing-mysql-on-os-x-mountain-lion/ It looks like you may simply need to unset TMPDIR prior to running the install_db command.

Redbeard011010
  • 954
  • 6
  • 20