Mac 安装配置Mysql
次阅读
2 min read
安装
brew install mysql@5.7 # 安装
brew link --force mysql@5.7 # 将mysql 5.7 版本设置为默认版本
brew services start mysql@5.7 # 启动服务,并将mysql 设置为开机自启服务
brew services list # 查看 mysql 是否成为开机自启服务
brew services stop mysql@5.7 # 停止
brew services restart mysql@5.7 # 重启
-
说明
The
brew services start mysql@5.7
- instruction is equal to :
$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
设置密码
启动之后,输入下面命令设置密码
mysql_secure_installation
5.7.x对设置的密码有严格的要求,分为LOW、MEDIUM、STRONG三个等级,对应要求如下:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
选low即可,输入8位,我这里使用pwd4root ,其他一路y确认即可。
启动
$ brew services start mysql@5.7
==> Successfully stopped `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)
登录
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.15 Homebrew