当前位置:网站首页>【5】Docker中部署MySQL
【5】Docker中部署MySQL
2022-08-05 05:26:00 【技术的搬运工】
1)拉取 mysql 镜像
docker pull mysql:8.0
2)创建容器
docker run -di --name=mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8.0
mysql 操作的一些命令:
service mysqld status # 查看 mysql 服务状态
service mysqld stop # 关闭 mysql 服务
service mysqld start # 开启 mysql 服务
关闭 mysql 服务
关闭宿主机的mysql服务后,删除之前创建的mysql容器,重新再创建并 设置 登陆密码为 123456
查看容器,发现 mysql 容器创建成功了,并且是启动和在线的状态
3)远程登陆 mysql
docker exec -it mysql /bin/bash # (连接宿主机的IP,指定端口为 3306)
登陆到 mysql 容器中
4)使用 mysql 命令打开客户端
mysql -u root -p 123456 --default-character-set=utf8 # --default-character-set=utf8 设置mysql默认的编码格式为 utf8
连接 mysql (这里的操作就跟平时语句操作mysql一样了)
5)连接 mysql 数据库
边栏推荐
- Complete mysql offline installation in 5 minutes
- GetEnumerator method and MoveNext and Reset methods in Unity
- DisabledDate date picker datePicker
- 网络排错基础-学习笔记
- Configuration of routers and static routes
- D45_Camera assembly Camera
- NB-IOT智能云家具项目系列实站
- Alibaba Cloud Video on Demand
- Four ways to obtain Class objects through reflection
- Error correction notes for the book Image Processing, Analysis and Machine Vision
猜你喜欢
随机推荐
如何将.asd恢复为Word文档
The cocos interview answers you are looking for are all here!
js 使用雪花id生成随机id
VSCode编写OpenCV
product learning materials
unity 将Text批量替换为TextMeshProUGUI
字体样式及其分类
深夜小酌,50道经典SQL题,真香~
H5 的浏览器存储
HelloWorld
Tips for formatting code indentation
Four ways to obtain Class objects through reflection
Some basic method records of commonly used languages in LeetCode
浏览器兼容汇总
D39_Vector
numpy.random使用文档
DevOps-了解学习
LeetCode中常用语言的一些基本方法记录
NB-IOT智能云家具项目系列实站
config.js相关配置汇总