一 安装mysql服务
1.1 拉取镜像
1.拉取: docker pull mysql:5.7.29
2.查看镜像: docker images
1.2 在宿主机创建文件存储mysql
1.创建映射目录:mysql-c5 在/root/export/dockertest 目录下,mkdir -p mysql-c5 ;映射mysql信息
1.3 创建容器
docker run -id --privileged=true \
-p 3306:3306 \
--name=c5_mysql \
-v $PWD/conf:/etc/mysql/conf.d \
-v $PWD/logs:/logs \
-v $PWD/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql:5.7.29
1.4 进入容器
root@localhost dockertest]# docker exec -it c5_mysql /bin/bash
root@5d6f5def65ce:/# mysql -uroot -p123456
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.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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 |
| sys |
+--------------------+
4 rows in set (0.00 sec)
1.5 远程连接
二 微服务工程
2.1 微服务工程创建
配置连接:
3.访问