Docker安装MySQL
2023-06-13 09:13:13 时间
Docker安装MySQL
docker search mysql
#搜索MySQL可用版本
[root@localhost ~]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11940 [OK]
mariadb MariaDB Server is a high performing open sou… 4562 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create… 896 [OK]
percona Percona Server is a fork of the MySQL relati… 567 [OK]
phpmyadmin phpMyAdmin - A web interface for MySQL and M… 419 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 92
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 90
centurylink/mysql Image containing mysql. Optimized to be link… 59 [OK]
databack/mysql-backup Back up mysql databases to... anywhere! 54
prom/mysqld-exporter 46 [OK]
deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r… 41 [OK]
tutum/mysql Base docker image to run a MySQL database se… 35
linuxserver/mysql A Mysql container, brought to you by LinuxSe… 34
schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 31 [OK]
mysql/mysql-router MySQL Router provides transparent routing be… 23
centos/mysql-56-centos7 MySQL 5.6 SQL database server 21
arey/mysql-client Run a MySQL client from a docker container 20 [OK]
fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron tas… 18 [OK]
openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6
ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 3 [OK]
idoall/mysql MySQL is a widely used, open-source relation… 3 [OK]
devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici… 3
jelastic/mysql An image of the MySQL database server mainta… 2
centos/mysql-80-centos7 MySQL 8.0 SQL database server 2
widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl… 1 [OK]
根据自己需要的版本进行下载镜像
如果使用最新镜像
docker pull mysql:latest
如果使用MySQL5.6版本
docker pull mysql:5.6
查看镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.6 dd3b2a5dcb48 2 weeks ago 303MB
mysql latest 3218b38490ce 2 weeks ago 516MB
运行容器
docker run -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.6
# -p 端口映射 3306(宿主机):3306(容器)
# -e 设置MySQL-root用户密码
查看容器运行情况
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7494de6b0200 mysql:5.6 "docker-entrypoint.s…" 39 seconds ago Up 39 seconds 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp mysql
测试MySQL是否可以正常使用
[root@localhost ~]# docker exec -it mysql bash
root@7494de6b0200:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql>
相关文章
- 验证MySQL实现身份证号码验证(mysql身份证)
- MySQL端口号:3306(mysql端口号多少)
- MySQL安装启动失败:排查与解决(mysql安装启动失败)
- 查看MySQL安装路径:快速操作指南(查询mysql安装路径)
- MySQL数据库程序设计:实现数据存储更高效率(mysql数据库程序设计)
- MySQL安装至D盘的简易指南(mysql安装到d盘)
- MySQL安装失败:无法启动服务(mysql安装完没有服务)
- 内数据利用Mysql查询指定时间段的数据(mysql查询一段时间)
- MySQL官方文档—完全指南(mysql的官方文档)
- 安装MySQL:使用Yum一步搞定(yum怎么安装mysql)
- 如何在虚拟机中安装MySQL(虚拟机如何安装mysql)
- 历史MySQL:自古以来的发展史(mysql发展)
- 如何轻松进入MySQL数据库?掌握这些技巧!(mysql怎么进去)
- 安装MySQL:了解默认密码(安装mysql默认密码)
- MySQL的存储引擎:强大的数据库功能(mysql的存储引擎)
- 初学者轻松上手MySQL(初学者安装mysql)
- MySQL版本管理指南: 实现更新迭代(mysql版本管理)
- 里MySQL安装使用指南(mysql装在哪)
- MySQL数据库怎样安装和使用?(mysql数据库在那)
- MySQL数据库结构对比及优势分析(mysql数据库结构对比)
- 如何查看MySQL安装是否成功?(查看mysql是否安装成功)
- C语言MySQL的异步操作实现思路(c mysql的异步实现)
- MySQL中如何使用DESC关键字进行表结构查询(mysql中desc表示)
- 解决MySQL中的1524错误问题(mysql中1524错误)
- 查看MySQL版本使用CMD命令(cmd看mysql版本)
- 使用CMD安装MySQL数据库的简单步骤(cmd安装mysql步骤)
- MySQL 32位安装简易指南(32位mysql如何安装)
- MySQL一键安装视频,轻松学习安装方法(mysql一键安装视频)
- MySQL查询不同字段的方法详解(mysql不同字段怎么查)
- 如何安装MySQL数据库(mysql下载解压后)
- MySQL二者择其一,两种安装方式(mysql 两种安装方式)
- MySQL三种Join快速了解左连接右连接和内连接(mysql三种join)