#离线做mysql升级
#去可有网络的docker
docker pull mysql:latest
#将mysql的镜像导出成tar文件到当前文件夹
docker save mysql:latest -o mysql.tar
#新无网络机器导入
docker load -i mysql.tar
#查看
#进入docker
docker exec -it 0e86322c372a /bin/bash
docker exec -it 0e86322c372a mysqldump -uroot -pJmkx2022 --all-databases > \
/tmp/bak_db_20240403.sql
#重启两个服务
docker-compose restart web mysql
#拉起
docker-compose -f docker-compose.yml up -d web mysql
#docker-compose restart mysql8.0
docker-compose -f docker-compose.yml up -d grafana
docker-compose.yml文件
version: '3'
services:mysql8.0:# 镜像名image: mysql:latest# 容器名(以后的控制都通过这个)container_name: mysql8.0# 重启策略restart: alwaysenvironment:# 时区上海# TZ: Asia/Shanghai# root 密码MYSQL_ROOT_PASSWORD: Jmkx2022# 映射端口ports:- 3306:3306volumes:- /mnt/mysql/mysql-datadir:/var/lib/mysql # 映射数据目录,宿主机:容器- /mnt/mysql/conf.d:/etc/mysql/conf.d # 映射配置目录,宿主机:容器- /mnt/mysql/mysql-log:/var/log/mysql #映射日志目录,宿主机:容器- /etc/localtime:/etc/localtime:ro # 让容器的时钟与宿主机时钟同步,避免时间的问题,ro是read only的意思,就是只读。command:# 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配)--default-authentication-plugin=mysql_native_password--character-set-server=utf8mb4--collation-server=utf8mb4_general_ci--explicit_defaults_for_timestamp=true--lower_case_table_names=1grafana:image: grafana/grafana:latest# 容器名(以后的控制都通过这个)container_name: grafananew# 重启策略restart: alwaysenvironment:GF_SECURITY_ADMIN_PASSWORD: adminports:- 3000:3000user: "472"volumes:- /var/lib/grafana:/var/lib/grafana # 映射数据目录,宿主机:容器- /var/log/grafana:/var/log/grafana # 映射日志目录,宿主机:容器- /etc/grafana/grafana.ini:/etc/grafana/grafana.ini # 映射配置目录,宿主机:容器- /var/lib/grafana/plugins/:/var/lib/grafana/plugins - /etc/localtime:/etc/localtime:ro#看日志查看问题#docker-compose logs grafana