Docker学习笔记之操作mysql
发布日期:2021-06-22 10:30:57 浏览次数:7 分类:技术文章

本文共 1043 字,大约阅读时间需要 3 分钟。

背景

记录下如何使用docker容器操作mysql数据库

方法

1、下载镜像

$ docker pull mysql:5.6

2、运行容器

$ docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.6

-e指定环境变量

3、进入容器

C:\Users\songzeceng>docker psCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES699ed4931f3e        mysql:5.6           "docker-entrypoint.s…"   13 seconds ago      Up 7 seconds        0.0.0.0:3306->3306/tcp   pensive_brattainC:\Users\songzeceng>docker exec -it 699ed4931f3e  /bin/bashroot@699ed4931f3e:/#

4、运行Mysql,输入密码root

root@699ed4931f3e:/# mysql -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.47 MySQL Community Server (GPL)Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

 

转载地址:https://blog.csdn.net/qq_37475168/article/details/105028913 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Docker学习笔记之阿里云远程镜像
下一篇:Docker学习笔记之Dockerfile的构建与编译

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2024年04月04日 20时18分43秒