【第二节】docker应用系列篇: docker运行单机mysql

系列文章目录

【第一节】docker应用系列篇: docker运行单机mysql

  • 系列文章目录
  • 前言
  • [一、 docker运行mysql容器](#一、 docker运行mysql容器)
  • [二、 客户端访问mysql](#二、 客户端访问mysql)

前言


提示:以下是本篇文章正文内容,下面案例可供参考

一、 docker运行mysql容器

c 复制代码
docker run -p 3306:3306 \
 --name mysql \
 -e MYSQL_ROOT_PASSWORD=root \
 -d \
 mysql:5.7

-v 命令说明: /opt/mysql/log:/var/log/mysql , : 前面是宿主机目录,如果不存在会自动创建,后面是容器的目录

-d 是后台运行

c 复制代码
docker ps 查询容器运行情况,如果发现没七情

二、 客户端访问mysql

c 复制代码
[root@vm31 ~]# docker exec -it mysql mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

相关推荐
灯澜忆梦9 小时前
【MySQL10】进阶篇 | 索引_#2性能优化
数据库·sql·mysql·性能优化
童槿顏丶11 小时前
docker自动化部署脚本
docker·eureka·自动化
油丶酸萝卜别吃14 小时前
MySQL B+ 树查询全过程详解
数据库·mysql
爱莉希雅&&&14 小时前
K8s NFS+StorageClass+PV/PVC+Deployment 实战笔记
笔记·容器·kubernetes
Cry丶14 小时前
遗留系统数据迁移实战(九):区域编码迁移与补偿接口设计
mysql·数据治理·数据迁移·区域编码·补偿接口·组织区域
GlueNa2SiO315 小时前
06-Docker存储与数据持久化
笔记·学习·docker
字节跳动数据库15 小时前
火山引擎 RDS MySQL 向量索引:把高性能向量检索带到 MySQL 上
人工智能·后端·mysql
一位正在转型AI全栈的前端工程师15 小时前
前端转全栈:从 502 到 200,我的第一个 Docker+Nginx+Node.js 项目
docker·容器
jason_renyu16 小时前
Linux Docker 服务管理与排查实战指南(新手速查版)
linux·docker·新手docker学习·docker日志查询·docker服务管理
小王C语言16 小时前
MySQL 库的操作:字符集和校验规则、数据库的增删查改、备份和还原
数据库·mysql