学习spring框架,按书上步骤走,卡在了第一步给root设置密码。搜了一圈也没合适的解决方法,最后自己尝试了一下解决了。
1、如果以前有安装过MySQL,按下面步骤彻底删除后在重新安装,避免一些奇怪的问题。下面步骤如果有执行不成功的可以忽略
- ps -ax | grep mysql
- 杀死所有与MySQL相关的进程
- brew remove mysql
- brew cleanup
- sudo rm /usr/local/mysql
- sudo rm -rf /usr/local/var/mysql
- sudo rm -rf /usr/local/mysql*
- sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
- sudo rm -rf /Library/StartupItems/MySQLCOM
- sudo 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
- 重启电脑
2、使用brew安装MySQL
安装MySQL:
brew install mysql
安装成功后启动mysql:
mysql.server start
设置root密码:
mysql_secure_installation
执行上面命令后会回答一些问题,其中有一个让你设置密码。