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

相关推荐
AI服务老曹5 小时前
架构实战:基于 GB28181 与 RTSP 的异构设备统一接入方案,深度解析 Docker 化 AI 视频管理平台
人工智能·docker·架构
落魄江湖行5 小时前
孤舟笔记 并发篇十一 行锁、间隙锁、临键锁傻傻分不清?MySQL InnoDB的锁其实就这三板斧
mysql·java并发·春招·孤舟笔记
叶总没有会5 小时前
Docker:项目部署
运维·docker·容器
爱学习 爱分享5 小时前
docker 本地装瀚高 4.5 数据库
数据库·docker·容器
zhoupenghui1685 小时前
Mysql插入数据时,怎么让自增的主键续接表当前最大ID+1
数据库·mysql·auto increment
song8546011345 小时前
MYSQL优化器的主要的优化策略及其示例
数据库·mysql
Bert.Cai5 小时前
MySQL RAND()函数详解
数据库·mysql
叶总没有会6 小时前
Docker入门
运维·docker·容器
发现你走远了6 小时前
极简后端环境搭建:一行 Docker 命令部署四大核心数据库(避坑 PG 18+)
数据库·docker·容器
身如柳絮随风扬6 小时前
使用 Docker 部署 GitLab 并分配用户账号 —— 保姆级教程
docker·容器·gitlab