Home  >  Article  >  Database  >  Upgrading the Docker installation of MySQL

Upgrading the Docker installation of MySQL

WBOY
WBOYforward
2023-09-16 09:09:07755browse

升级 MySQL 的 Docker 安装

Before upgrading your docker installation of MySQL, make sure to follow these steps -

  • Download the MySQL server docker image.

  • Start the MySQL server instance.

  • Connect to the MySQL server instance from within the container.

Here are the steps to upgrade a Docker installation of MySQL 5.7 to 8.0 -

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

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

  • Start new MySQL 5.7 Docker container data and configuration.

  • Modify as needed.

  • If a MySQL community server exists, run the following 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 necessary, change mysql/mysql- server adjusted to the correct repository name.

  • Wait for the server to complete the startup operation.

  • You can use the "docker ps" command to check the status of the server.

  • Run the mysql_upgrade utility in the MySQL 5.7 Server container using the following command -

docker exec -it mysql57 mysql_upgrade -uroot -p
  • When prompted, Enter the root password of the old MySQL 5.6 server.

  • Complete the upgrade by restarting MySQL 5.7 server container using the following command -

docker restart mysql57

The above is the detailed content of Upgrading the Docker installation of MySQL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete