【第二节】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.

相关推荐
用户8307196840822 天前
Java 告别繁琐数据统计代码!MySQL 8 窗口函数真香
java·sql·mysql
stark张宇2 天前
MySQL 核心内幕:从索引原理、字段选型到日志机制与外键约束,一篇打通数据库任督二脉
数据库·mysql·架构
Java陈序员2 天前
轻量强大!一款现代化的 Kubernetes 集群管理与监控工具!
云原生·容器·kubernetes
Hoffer_3 天前
MySQL 强制索引:USE/FORCE INDEX 用法与避坑
后端·mysql
Hoffer_3 天前
MySQL 索引核心操作:CREATE/DROP/SHOW
后端·mysql
Sheffield4 天前
Docker的跨主机服务与其对应的优缺点
linux·网络协议·docker
Sheffield4 天前
Alpine是什么,为什么是Docker首选?
linux·docker·容器
马艳泽4 天前
win10下运行Start Broker and Proxy报错解决
docker
0xDevNull5 天前
MySQL索引进阶用法
后端·mysql
0xDevNull5 天前
MySQL索引用法
mysql