MySQL部署
本文档分为docker部署与物理环境部署
docker部署MySQL
-
拉取mysql官方镜像(dockerhub/https://hub.daocloud.io/)
-
创建目录--存放mysql数据文件
-
创建docker-compose.yml文件
-
运行
docker下部署命令
docker pull daocloud.io/library/mysql:5.7.4
mkdir -p /data/mysql
cd /data/mysql
mkdir data //创建数据存放目录
mkdir conf //创建配置存放目录
vim docker-compose.yml //编辑或创建该文件--详情见下文
docker-compose up -d //启动该
docker-compose.yml 示例
version: "3.2"
services:
mysql:
image: daocloud.io/library/mysql:5.7.4
container_name: mysql
restart: always
ports:
- 3306:3306
volumes:
- /data/mysql/config:/etc/mysql/conf.d
- /data/mysql/logs:/var/logs
- /data/mysql/data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=123456