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

相关推荐
奋斗的蛋黄41 分钟前
KEDA 深度解析:K8s 事件驱动自动扩缩容的核心实践
云原生·容器·kubernetes
合作小小程序员小小店2 小时前
web网页开发,在线短视频管理系统,基于Idea,html,css,jQuery,java,springboot,mysql。
java·前端·spring boot·mysql·vue·intellij-idea
猿小喵2 小时前
浅谈MySQL主从复制
数据库·mysql
Dxy12393102162 小时前
MySQL如何修改最大连接数
数据库·mysql
UCoding2 小时前
我们来学mysql -- delete undo log的形成
数据库·mysql·delete的undo log
TDengine (老段)2 小时前
TDengine 字符串函数 REGEXP_IN_SET 用户手册
数据库·物联网·mysql·时序数据库·tdengine·涛思数据
ITVV2 小时前
Docker 安装配置
运维·docker·容器
合作小小程序员小小店3 小时前
web开发,在线%小区,物业%管理系统,基于idea,html,jsp,java,ssm,mysql数据库
java·数据库·mysql·jdk·intellij-idea
m***11903 小时前
Redis 设置密码(配置文件、docker容器、命令行3种场景)
数据库·redis·docker
小吕学编程3 小时前
MySQL分区(Partition)实战指南
数据库·mysql