How to migrate MySQL data directory in docker container?

前端 未结 2 1980
独厮守ぢ
独厮守ぢ 2021-02-19 07:43

I have a docker container running MySQL-5.5 with host data volume. I am upgrading my container to MySQL-5.6. I am starting a new container with the same host volume. MySQL was c

2条回答
  •  遥遥无期
    2021-02-19 08:17

    You could start MySQL using the 5.5 image and run mysqldump against it

    docker run --rm --link mysqld mysql:5.5 \
           mysqldump -h mysqld --all-databases > /your/host/machine/
    

    And then start a new container using the 5.6 image and initialize it using the SQL dump

    docker run -v /data/your_dump.sql:/docker-entrypoint-initdb.d/dump.sql mysql:5.6
    

提交回复
热议问题