Ubuntu18.4使用docker安装mysql
作者:互联网
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'; #查看授权
- 退出后用新建用户测试登录是否成功
标签:Ubuntu18.4,identified,usr,mysql,docker,local,ljbb 来源: https://blog.csdn.net/weixin_39726347/article/details/119387608