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

相关推荐
ldj202022 分钟前
Docker的docker-compose类比Spring的ApplicationContext
spring·docker
ldj20201 小时前
docker 自定义网桥作用
docker·容器
java叶新东老师1 小时前
k8s常用命令
云原生·容器·kubernetes
土豆丶杨3 小时前
centos 配置docker
docker·eureka·centos
fengye2071613 小时前
板凳-------Mysql cookbook学习 (十二--------6)
学习·mysql·adb
杰哥的狗3 小时前
nacos连接失败,启动失败常见问题
linux·docker
DarkAthena3 小时前
【GaussDB】构建一个GaussDB的Docker镜像
数据库·docker·gaussdb
qq_529835355 小时前
Mysql中的锁
数据库·mysql·oracle
佛祖让我来巡山5 小时前
【InnoDB优化的两大法器】内存池与后台线程解析
mysql·innodb
看天走路吃雪糕6 小时前
墨者:SQL手工注入漏洞测试(MySQL数据库)
数据库·mysql·sql注入·墨者靶场