1.拉取镜像
docker pull mysql:5.7
2.下载设置安装mysql5.7
docker run --restart=always --name=mysql5.7 --privileged=true -p 3306:3306 -v /Users/mac/Docker/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
3.进入容器病修改初始密码
docker exec -it mysql5.7 /bin/bash
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
update user set host = '%' where user = 'root';
FLUSH PRIVILEGES;
4.在本地mac通过Navicat软件连接mysql即可使用