1,安装支持rancher 的docker,方便后期做集群管理
curl https://releases.rancher.com/install-docker/18.09.sh | sh
2,docker安装mysql,映射本地目录
docker run -p 3306:3306 --name mysql \ -v /usr/local/docker/mysql/conf:/etc/mysql \ -v /usr/local/docker/mysql/logs:/var/log/mysql \ -v /usr/local/docker/mysql/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=123456 \ -d mysql:5.7
3,测试mysql链接
docker exec -it mysql bash mysql -uroot -p123456
4,添加用户并授权(root登录mysql控制台执行)
create user ljbb identified by 'ljbb@123'; # create user 账号 identified by '密码';
grant all privileges on lijia_ehr.* to ljbb@'localhost' identified by 'ljbb@123'; #授权 flush privileges; #刷新 show grants for 'ljbb'; #查看授权