1. 安装Homebrew

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. 查看版本库中的MySQL

1
brew info mysql

3. 安装MySQL

1
brew install mysql

4. 安装brew service

1
brew tap homebrew/services

5. 查看安装的MySQL

1
mysql -V

6. 启动MySQL

启动为后台MySQL并设置开机启动

1
brew services start mysql

直接启动

1
mysql.server start

7. 设置root密码

1
mysqladmin -u root password 'yourpassword'

8. 连接登陆MySQL

1
mysql -u root -p

9. 查看安装后的字符集

1
show variables like '%char%';

10. 查看brew 安装的service

1
brew services list

11. 关闭MySQL

1
mysql.server stop