查看mysql镜像
https://container-registry.oracle.com/
创建容器mysql5.7
从oracle容器仓库中拉取mysql 5.7社区版本
[root]# docker pull container-registry.oracle.com/mysql/community-server:5.7
查看镜像信息
[root]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
container-registry.oracle.com/mysql/community-server 5.7 55db19768c9c 2 years ago 375MB
宿主机创建相关目录
[root]# mkdir -p /data/docker_mysql5.7_01/{data,etc}
配置my.cnf文件
[root]# vi /data/docker_mysql5.7_01/etc/my.cnf
[mysqld]
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
secure-file-priv=/var/lib/mysql-files
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
创建mysql5.7_01容器
[root]# docker run --name=mysql5.7_01 --mount type=bind,src=/data/docker_mysql5.7_01/data,dst=/var/lib/mysql --mount type=bind,src=/data/docker_mysql5.7_01/etc/my.cnf,dst=/etc/my.cnf -p 3301:3306 --env MYSQL_ROOT_PASSWORD=Gaoyu@029 -d 55db19768c9c
升级容器mysql5.7到mysql8.0
拉取mysql8.0社区版镜像
[root]# docker pull container-registry.oracle.com/mysql/community-server:8.0
查看镜像信息
[root]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
container-registry.oracle.com/mysql/community-server latest ed3919bfd3bd 4 weeks ago 546MB
从mysql 5.7升级到8.0
[root]# docker run --name=mysql8.0_01 --mount type=bind,src=/data/docker_mysql5.7_01/data,dst=/var/lib/mysql --mount type=bind,src=/data/docker_mysql5.7_01/etc/my.cnf,dst=/etc/my.cnf -p 3301:3306 --env MYSQL_ROOT_PASSWORD=Gaoyu@029 -d ed3919bfd3bd
参考:https://dev.mysql.com/doc/refman/8.0/en/docker-mysql-getting-started.html
标签:01,部署,mysql5.7,--,mysql,docker,data From: https://www.cnblogs.com/haha029/p/17421115.html