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

边栏推荐
猜你喜欢
![In-depth analysis if according to data authority @datascope (annotation + AOP + dynamic sql splicing) [step by step, with analysis process]](/img/b5/03f55bb9058c08a48eae368233376c.png)
In-depth analysis if according to data authority @datascope (annotation + AOP + dynamic sql splicing) [step by step, with analysis process]

Get the network input dimensions of the pretrained model

cs231n learning record

多线程之传递参数

After docker is deployed, mysql cannot connect

BIO, NIO, AIO practical study notes (easy to understand theory)

数组&的运算

System basics - study notes (some command records)

Nacos集群的搭建过程详解

DisabledDate date picker datePicker
随机推荐
白鹭egret添加新页面教程,如何添加新页面
深夜小酌,50道经典SQL题,真香~
【FAQ】CCAPI兼容EOS相机列表(2022年8月 更新)
浏览器兼容汇总
Late night drinking, 50 classic SQL questions, really fragrant~
记录vue-页面缓存问题
Get the network input dimensions of the pretrained model
H5开发调试-Fiddler手机抓包
LeetCode中常用语言的一些基本方法记录
Browser Storage for H5
滚动条问题,未解决
Q 2020, the latest senior interview Laya soul, do you know?
七种让盒子水平垂直居中的方法
VSCode编写OpenCV
指针常量与常量指针 巧记
Vim tutorial: vimtutor
Programmers should understand I/O this way
图像处理、分析与机器视觉一书纠错笔记
盒子模型小练习
LaTeX uses frame to make PPT pictures without labels