当前位置:网站首页>【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 数据库

边栏推荐
- Writing OpenCV in VSCode
- NB-IOT智能云家具项目系列实站
- 指针常量与常量指针 巧记
- Transformer interprets and predicts instance records in detail
- wc, grep, tar, vi/vim
- BIO, NIO, AIO practical study notes (easy to understand theory)
- input detailed file upload
- 数组&的运算
- 白鹭egret添加新页面教程,如何添加新页面
- One-arm routing experiment and three-layer switch experiment
猜你喜欢
随机推荐
Seven Ways to Center a Box Horizontally and Vertically
D45_Camera assembly Camera
【FAQ】CCAPI兼容EOS相机列表(2022年8月 更新)
cs231n learning record
【考研结束第一天,过于空虚,想对自己进行总结一下】
LaTeX使用frame制作PPT图片没有标号
亚马逊美国站:马术头盔CPC认证标准要求
uniapp打包次数限制怎么办?只需两步就能解决
系统基础-学习笔记(一些命令记录)
Come, come, let you understand how Cocos Creator reads and writes JSON files
D39_Eulerian Angles and Quaternions
ES2020新特性
ev加密视频转换成MP4格式,亲测可用
指针常量与常量指针 巧记
LeetCode练习及自己理解记录(1)
Collision, character controller, Cloth components (cloth), joints in the Unity physics engine
数组&的运算
Network Protocol Fundamentals - Study Notes
May I ask how to read the binlog of the two tables of hologres through flink sql, and then how to join?
vs2017关于函数命名方面的注意事项








