mac 安装 mysql 5.7

原创
2020/07/05 22:40
阅读数 90

卸载以前的版本

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
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

brew services list
brew services stop mysql@5.6
brew remove mysql@5.6
rm -rf /usr/local/var/mysql

安装

brew install mysql@5.7
brew services start mysql@5.7

初始化,记下初始密码

mysqld --initialize --datadir=/data/mysql

修改 plist 中的 datadir

vim ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist 

重新启动 mysql

brew services restart mysql@5.7
ps aux|grep mysql   #查看 datadir 是否已经改变!

修改密码

mysql -uroot -p #输入刚才记下的密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

完工。

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部