【MySQL 18】Docker 安装 MySQL8 .0.30
创始人
2024-03-02 14:40:45
0

1、查看可用的 MySQL 版本

访问 MySQL 镜像库地址:

https://hub.docker.com/_/mysql?tab=tags 。

在这里插入图片描述
在这里插入图片描述

2、拉取 MySQL 8.0.30 镜像

拉取官方的指定版本的镜像:

docker pull mysql:8.0.30
[root@localhost deploy]# docker pull mysql:8.0.30
8.0.30: Pulling from library/mysql
295ca2342728: Pull complete 
79af4312a7e0: Pull complete 
48d3d73d1704: Pull complete 
521b8724b397: Pull complete 
b8cf360b4a14: Pull complete 
0115482cc006: Pull complete 
a360b08917ea: Pull complete 
12deeb3c1323: Pull complete 
ee1dc10db1e9: Pull complete 
64be404ad29c: Pull complete 
1921fe8879a2: Pull complete 
Digest: sha256:3c1aab708f6e57fc4dccafe36baccc7219acfb4ec450f3fb6d370ea89409e906
Status: Downloaded newer image for mysql:8.0.30
docker.io/library/mysql:8.0.30

3、查看本地镜像

使用以下命令来查看是否已安装了 mysql:

docker images
[root@localhost deploy]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
mysql        8.0.30    dbaea59d1b41   7 weeks ago   449MB

在上图中可以看到我们已经安装了8.0.30版本的 mysql 镜像。

在这里插入图片描述

4、运行容器

docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.30

参数说明:

  • -p 3306:3306 :映射容器服务的 3306 端口到宿主机的 3306 端口,外部主机可以直接通过 宿主机ip:3306 访问到 MySQL 的服务。

  • MYSQL_ROOT_PASSWORD=123456:设置 MySQL 服务 root 用户的密码

[root@localhost deploy]# docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.30
aab502119678b471aa2c7cb4e0b2d5f091c65e46db0e48be76f462dccb5a1d4c

在这里插入图片描述

5、安装成功

通过 docker ps 命令查看是否安装成功:

[root@localhost deploy]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                                                  NAMES
aab502119678   mysql:8.0.30   "docker-entrypoint.s…"   5 minutes ago   Up 5 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   mysql-test

在这里插入图片描述
可以通过 root 和密码 123456 访问 MySQL 服务。

[root@localhost deploy]# docker exec -it mysql-test /bin/bash  #进入MySQL容器
bash-4.4# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.30 MySQL Community Server - GPLCopyright (c) 2000, 2022, 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.mysql> 

在这里插入图片描述

相关内容

热门资讯

AWSECS:访问外部网络时出... 如果您在AWS ECS中部署了应用程序,并且该应用程序需要访问外部网络,但是无法正常访问,可能是因为...
AWSElasticBeans... 在Dockerfile中手动配置nginx反向代理。例如,在Dockerfile中添加以下代码:FR...
银河麒麟V10SP1高级服务器... 银河麒麟高级服务器操作系统简介: 银河麒麟高级服务器操作系统V10是针对企业级关键业务...
北信源内网安全管理卸载 北信源内网安全管理是一款网络安全管理软件,主要用于保护内网安全。在日常使用过程中,卸载该软件是一种常...
AWR报告解读 WORKLOAD REPOSITORY PDB report (PDB snapshots) AW...
AWS管理控制台菜单和权限 要在AWS管理控制台中创建菜单和权限,您可以使用AWS Identity and Access Ma...
​ToDesk 远程工具安装及... 目录 前言 ToDesk 优势 ToDesk 下载安装 ToDesk 功能展示 文件传输 设备链接 ...
群晖外网访问终极解决方法:IP... 写在前面的话 受够了群晖的quickconnet的小水管了,急需一个新的解决方法&#x...
不能访问光猫的的管理页面 光猫是现代家庭宽带网络的重要组成部分,它可以提供高速稳定的网络连接。但是,有时候我们会遇到不能访问光...
Azure构建流程(Power... 这可能是由于配置错误导致的问题。请检查构建流程任务中的“发布构建制品”步骤,确保正确配置了“Arti...