How to migrate MySQL data directory in docker container?

谁都会走 提交于 2019-12-04 02:22:30

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

I believe you need to modify your dockerfile to run mysql-upgrade before starting mysql. Although you might need to repair it as well as described in the references you provided. You should only need to run it once, then you can remove it from dockerfile. (I assume database is actually stored on the host file system and mounted in the docker.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!