brew|brew mysql

1、homebrew安装
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、命令使用
安装软件:brew install 软件名,例:brew install wget
搜索软件:brew search 软件名,例:brew search wget
卸载软件:brew uninstall 软件名,例:brew uninstall wget
更新所有软件:brew update
更新具体软件:brew upgrade 软件名 ,例:brew upgrade git
显示已安装软件:brew list
查看软件信息:brew info/home 软件名 ,例:brew info git / brew home git
显示包依赖:brew reps
显示安装的服务:brew services list
安装服务启动、停止、重启:brew services start/stop/restart serverName
3、homebrew cask安装
rew install brew-cask-completion
brew install mysql@5.7
brew tap homebrew/services
启动mysql服务 【brew|brew mysql】brew services start mysql
获取 service 列表 brew services list
重启 mysql 服务 brew services restart mysql
停止 mysql 服务 brew services stop mysql
1.安装后第一次设置root 以及初始化配置(/usr/local/Cellar/mysql@5.7/5.7.23/bin目录下)
mysql_secure_installation
2.链接数据库
mysql -uroot
3.设置环境变量
echo 'export PATH="/usr/local/Cellar/mysql@5.7/5.7.23/bin:$PATH"' >> ~/.zshrc
4.加载环境变量配置
exec zsh
5.启动mysql
brew services start mysql@5.7
原生安装
mysql export PATH=${PATH}:/usr/local/mysql/bin
alias mysqlstart='sudo /usr/local/mysql/support-files/mysql.server start'
alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop'
数据丢失备份
重启电脑,按住Command+R(直到出现苹果标志)进入Recovery Mode(恢复模式)
左上角菜单里找到实用工具 -> 终端
输入csrutil disable回车 重启Mac即可 如果想重新启动SIP机制重复上述步骤改用 csrutil enable即可
查看SIP状态:
$ csrutil status

    推荐阅读