部署 mysql:5.7
安装
mkdir -p /app/docker/mysql/log
mkdir -p /app/docker/mysql/data
mkdir -p /app/docker/mysql/conf
docker pull mysql:5.7
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /app/docker/mysql/conf.d:/etc/mysql/conf.d -v /app/docker/mysql/data:/var/lib/mysql -v /app/docker/mysql/log:/var/log/mysql/ --name mysql mysql:5.7
docker exec -it mysql bash
docker exec -it mysql /bin/bash
mysql -uroot -p123456
移除
docker stop $(docker ps -aqf "name=mysql")
docker start $(docker ps -aqf "name=mysql")
docker rm $(docker ps -aqf "name=mysql")
docker rmi $(docker images -q mysql )
参数说明
- p 3306:3306:将容器的3306端口映射到主机的3306端口
- v /app/docker/mysql/conf:/etc/mysql:将配置文件夹挂在到主机
- v /app/docker/mysql/log:/var/log/mysql:将日志文件夹挂载到主机
- v /app/docker/mysql/data:/var/lib/mysql/:将数据文件夹挂载到主机
- e MYSQL_ROOT_PASSWORD=root:初始化root用户的密码
mysql.cnf
mysql.cnf
扩展查询
查询某个数据库,指定数据库名:打开information_schema,在它之下查询
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='XXX';
mkdir -p /app/docker/mysql/data
mkdir -p /app/docker/mysql/conf
mkdir -p /app/docker/mysql/log
docker pull mysql:latest
docker run -p 3306:3306 --name mysql \
-v /app/docker/mysql/log:/var/log/mysql \
-v /app/docker/mysql/data:/var/lib/mysql \
-v /app/docker/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql:
docker exec -it mysql bash
docker exec -it mysql /bin/bash
mysql -uroot -p123456
标签:教程,log,app,Mysql,conf,mysql,3306,docker
From: https://www.cnblogs.com/sopcce/p/17052884.html