docker 安装mysql
PassJava (佳必过) 项目全套学习教程连载中,第一时间获取。
docker 安装mysql
1.下载镜像
sudo docker pull mysql:5.7
:~$ sudo docker pull mysql:5.7 5.7: Pulling from library/mysql c499e6d256d6: Pull complete 22c4cdf4ea75: Pull complete 6ff5091a5a30: Pull complete 2fd3d1af9403: Pull complete 0d9d26127d1d: Pull complete 54a67d4e7579: Pull complete fe989230d866: Pull complete 466a91a95e2f: Pull complete 3e4554c238f1: Pull complete 603b48ead88c: Pull complete 1e86a9aa7171: Pull complete Digest: sha256:fbaeced79cfdae5d3c8d4a8c41e883f254f72ed7428c6b93a498824b76d97121 Status: Downloaded newer image for mysql:5.7 docker.io/library/mysql:5.7
2.查看下载的镜像
sudo docker images
3.创建mysql实例并启动
- 创建mysql实例并启动
sudo docker run -p 3306:3306 --name mysql -v /mydata/mysql/log:/var/log/mysql -v /mydata/mysql/data:/var/lib/mysql -v /mydata/mysql/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7 参数说明 -p 3306:3306 将容器的3306端口映射到主机 -v /mydata/mysql/log:/var/log/mysql\ 将日志文件挂载到主机 -v /mydata/mysql/data:/var/lib/mysql\ 将数据文件挂载到主机 -v /mydata/mysql/conf:/etc/mysql\ 将配置文件挂载到主机
查看docker容器
mysql容器已启动
4.连接数据库
- 用Workbench连接数据库
- 查看数据库
5.进入mysql 容器
sudo docker exec -it mysql /bin/bash
6.查看虚拟机映射文件
cd /mydata/mysql ls
公众号
相关推荐
王道革 2020-11-25
bwyyziq 2020-11-22
pigsmall 2020-11-19
changecan 2020-11-19
helloWorldAndYou 2020-11-16
nginxs 2020-11-14
红石丶 2020-11-13
WanKaShing 2020-11-12
yangkang 2020-11-12
滴水穿石点石成金 2020-11-12
张荣珍 2020-11-12
wuxunanjing 2020-11-11
魅惑青花瓷 2020-11-11
lihongtai 2020-11-09
yangkang 2020-11-09
worldsnow 2020-11-06
MichaelJScofield 2020-11-06
TaoTaoFu 2020-11-06