Upgrading a Docker Installation of MySQL

MySQLMySQLi Database

Before upgrading the docker installation of MySQL, ensure that the below mentioned steps have been followed −

  • Download a MySQL server docker image.

  • Start a MySQL server instance.

  • Connect to MySQL server instance from within the container.

Following are the steps to upgrade a Docker installation of MySQL 5.7 to 8.0 −

  • Stop the MySQL 5.6 server using the below command. Here mysql56 is the name of the container.

docker stop mysql56
  • Download the MySQL 5.7 Server Docker image.

  • Start a new MySQL 5.7 Docker container with the help of the old server data and configuration.

  • Perform modifications if required.

  • If MySQL community server is present, run the below command −

docker run --name=mysql57 \
--mount type=bind,src=/path-on-host-machine/my.cnf,dst=/etc/my.cnf \
--mount type=bind,src=/path-on-host-machine/datadir,dst=/var/lib/mysql \
-d mysql/mysql-server:5.7
  • If required, adjust mysql/mysql-server to the correct repository name.

  • Wait for the server to finish the startup operations.

  • The status of the server can be checked for using the ‘docker ps’ command.

  • Run the mysql_upgrade utility in the MySQL 5.7 Server container using the below command −

docker exec -it mysql57 mysql_upgrade -uroot -p
  • When it prompts, enter the root password for the old MySQL 5.6 Server.

  • Finish the upgrade by restarting the MySQL 5.7 Server container using the below command −

docker restart mysql57
raja
Published on 08-Mar-2021 12:05:57
Advertisements