我是靠谱客的博主 有魅力母鸡,最近开发中收集的这篇文章主要介绍docker安装mysql5.7.11,Docker安装Mysql 5.7并使用,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1. 环境

操作系统: Linux - Centos7

Docker版本: Docker-CE 19.03.13

Mysql版本: 5.7

2. 前置准备

安装docker

3. 安装

3.1 创建挂载文件夹

mkdir -p /home/mysql-docker/conf

mkdir -p /home/mysql-docker/logs

mkdir -p /home/mysql-docker/mysql

3.2 安装

docker pull mysql:5.7

3.3 查看images镜像

[root@bogon docker]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

mysql 5.7 1b12f2e9257b 5 days ago 448MB

3.4 启动Mysql5.7

docker run -d --privileged=true --name mysql -p 13306:3306

-v /home/mysql-docker/conf:/etc/mysql/

-v /home/mysql-docker/logs:/logs

-v /home/mysql-docker/mysql:/var/lib/mysql

-e MYSQL_ROOT_PASSWORD=root

mysql:5.7

3.5 查看启动状态

[root@bogon docker]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

f7726ecba2a2 mysql:5.7 "docker-entrypoint.s…" 14 seconds ago Up 13 seconds 33060/tcp, 0.0.0.0:13306->3306/tcp mysql

3.6 查看启动日志

docker logs f77

2020-10-28T03:05:34.756739Z 0 [Note] Plugin 'FEDERATED' is disabled.

2020-10-28T03:05:34.766346Z 0 [Note] InnoDB: Buffer pool(s) load completed at 201028 3:05:34

2020-10-28T03:05:34.770925Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.

2020-10-28T03:05:34.770963Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.

2020-10-28T03:05:34.772922Z 0 [Warning] CA certificate ca.pem is self signed.

2020-10-28T03:05:34.773035Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.

2020-10-28T03:05:34.774294Z 0 [Note] Server hostname (bind-address): '*'; port: 3306

2020-10-28T03:05:34.775517Z 0 [Note] IPv6 is available.

2020-10-28T03:05:34.775555Z 0 [Note] - '::' resolves to '::';

2020-10-28T03:05:34.775614Z 0 [Note] Server socket created on IP: '::'.

2020-10-28T03:05:34.843091Z 0 [Note] Event Scheduler: Loaded 0 events

2020-10-28T03:05:34.843567Z 0 [Note] mysqld: ready for connections.

Version: '5.7.32' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)

3.7 使用navcat连接

url: localhost:13306

用户名密码: root/root

连接成功

dc9a7002eb1f

image.png

3.8 也可以使用命令行进入容器内,查看数据库

docker exec -it mysql /bin/bash

[root@bogon docker]# docker exec -it mysql /bin/bash

root@f7726ecba2a2:/# mysql -uroot -proot

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.00 sec)

最后

以上就是有魅力母鸡为你收集整理的docker安装mysql5.7.11,Docker安装Mysql 5.7并使用的全部内容,希望文章能够帮你解决docker安装mysql5.7.11,Docker安装Mysql 5.7并使用所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部