问题
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.
回答1:
All credit goes to coder wall
Remove MySQL completely
ps -ax | grep mysqlstop and kill any MySQL processesbrew remove mysqlbrew cleanupsudo rm /usr/local/mysqlsudo rm -rf /usr/local/var/mysqlsudo rm -rf /usr/local/mysql*sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plistsudo rm -rf /Library/StartupItems/MySQLCOMsudo rm -rf /Library/PreferencePanes/My*launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist- edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*sudo rm -rf /Library/Receipts/mysql*sudo rm -rf /Library/Receipts/MySQL*sudo rm -rf /private/var/db/receipts/*mysql*- edit ~/.bash_profile and remove any aliases for mysql or mysqlAdmin
- restart your computer just to ensure any MySQL processes are killed try to run mysql, it shouldn't work
Reinstall MySQL with Homebrew
brew doctorbrew updatebrew install mysqlunset TMPDIRmysqld -initialize --log-error-verbosity --user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmpmysql.server startbrew services start mysql
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/34345726/brew-install-mysql-on-mac-os-el-capitan