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

相关推荐
jakeswang3 小时前
全解MySQL之死锁问题分析、事务隔离与锁机制的底层原理剖析
数据库·mysql
一成码农4 小时前
MySQL问题7
数据库·mysql
慕容晓开4 小时前
docker,本地目录挂载
docker
Kt&Rs5 小时前
MySQL复制技术的发展历程
数据库·mysql
手握风云-5 小时前
MySQL数据库精研之旅第十六期:深度拆解事务核心(上)
数据库·mysql
Mr. Cao code6 小时前
Docker:颠覆传统虚拟化的轻量级革命
linux·运维·ubuntu·docker·容器
Dontla6 小时前
Docker多共享网络配置策略(Docker多网络、Docker networks、Docker Compose网络、Docker网络、Docker共享网络)
网络·docker·容器
Jayin_chan7 小时前
paddlex3.0.1-ocr服务化安装部署(docker)
docker·容器·ocr
叫我龙翔7 小时前
【MySQL】从零开始了解数据库开发 --- 库的操作
数据库·mysql·数据库开发
ifanatic7 小时前
[每周一更]-(第159期):Go 工程师视角:容器化技术(Docker/Kubernetes)与CI/CD流程的应用场景
docker·golang·kubernetes