Docker安装MySQL
2022/4/7 19:19:32
本文主要是介绍Docker安装MySQL,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
此处拿mysql5.7作为示范
1.安装mysql5.7镜像
docker pull mysql:5.7 5.7: Pulling from library/mysql f003217c5aae: Already exists 65d94f01a09f: Already exists 43d78aaa6078: Already exists a0f91ffbdf69: Already exists 59ee9e07e12f: Already exists 04d82978082c: Already exists 70f46ebb971a: Already exists ba61822c65c2: Pull complete dec59acdf78a: Pull complete 0a05235a6981: Pull complete c87d621d6916: Pull complete Digest: sha256:1a73b6a8f507639a8f91ed01ace28965f4f74bb62a9d9b9e7378d5f07fab79dc Status: Downloaded newer image for mysql:5.7 docker.io/library/mysql:5.7
2. 启动mysql容器
docker run -d -p 3306:3306 -v E:\dockerWorkspace\mysql5.7\conf:/etc/mysql/conf.d -v E:\dockerWorkspace\mysql5.7\data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root --name mysql57 mysql:5.7 # 参数解析 -d 后台运行 -v 挂载卷 主机目录:容器目录 可挂载多个卷 -e 设置参数 此处设置MYSQL初始密码 --name 设置容器名称
3. 检测是否启动成功
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 340468efcecf mysql:5.7 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysql57
这篇关于Docker安装MySQL的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2025-01-02MySQL 3主集群搭建
- 2024-12-25如何部署MySQL集群资料:新手入门教程
- 2024-12-24MySQL集群部署资料:新手入门教程
- 2024-12-24MySQL集群资料详解:新手入门教程
- 2024-12-24MySQL集群部署入门教程
- 2024-12-24部署MySQL集群学习:新手入门教程
- 2024-12-24部署MySQL集群入门:一步一步搭建指南
- 2024-12-07MySQL读写分离入门:轻松掌握数据库读写分离技术
- 2024-12-07MySQL读写分离入门教程
- 2024-12-07MySQL分库分表入门详解