1. Back up the old MySQL5.7 dataRemember to back up old data first to prevent data loss due to upgrade failure. There are two ways to back up. One is to directly execute the export command on the host machine, and the other is to enter the Docker environment first to perform the operation. The main export commands are as follows: #Method 1: Back up data directly on the host machine# 0df568 is the docker id; -uroot -p123456 is the username and password; dbA dbB is the data to be backed up, --databases can be followed by multiple database names, and the exported sql is to /root/all-databases3306.sql docker exec -it 0df568 mysqldump -uroot -p123456 --databases dbA dbB > /root/all-databases3306.sql #======================================================================================================================================================== #Method 2: Enter docker first and execute mysqldump, then copy the exported sql to the host #Enter docker first docker exec -it 0df568 /bin/bash #Optional source /etc/profile #Execute the export command mysqldump -uroot -p123456 --databases dbA dbB > /root/all-databases3306.sql #Copy to the host machine#Exit Docker and execute the exit command exit #At this point, you are already in the host environment. Execute the copy command to copy the sql file from docker red. docker cp 0df568:/root/all-databases3306.sql /root/all-databases3306.sql 2. Pull the image of MySQL8.0.13 and complete the installationYou can actually refer to the official website to pull and install MySQL. Reference URL: https://hub.docker.com/r/mysql/mysql-server/. Here is a brief description of the installation process. 2.1 Pull the image to localRun the following command to pull the latest MySQL image docker pull mysql/mysql-server:lastest Pull the specified MySQL image #tag is to fill in the version number you want. For example, if you want MySQL8.0.13, then the tag is You can use docker images to view the progress you pulled down. 2.2 Run MySQL 8.0.13 imageRun the specified MySQL8.0.13 Docker image. We have already pulled the specified image in step 2.1. Then we can view the local Docker image through docker images and get the image ID and name. Next, run the following command to run the Docker image of MySQL 8.0.13: #--name specifies the name after running and starting -e specifies the environment variables in docker -v partition or directory mapping, docker program data is mapped to the specified location of the host -p specifies the port mapping from the host to the docker program -d specifies the version of the image. docker run --name=mysql8.0 -e MYSQL_ROOT_PASSWORD=123456 -v /root/dockerdata/mysql8.0/data:/var/lib/mysql -p 3307:3306 -dit mysql/mysql-server:8.0.13 Check if it is running # Execute the following command docker ps 3. Some problems after upgrading to MySQL 8.XAfter upgrading MySQL 8.x, remote connections cannot be connected, which is very inconvenient and needs to be modified. It mainly includes the following two aspects of configuration: 3.1 Providing Remote AccessChange the user to @'%', % means all hosts can connect, the command is as follows: #First log in to the database as root and execute the following commands #a. Use msyql use mysql; #b. Then execute authorization GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY '123456' #c. Be sure to refresh the permissions (reload), otherwise you need to restart MySQL to take effect FLUSH PRIVILEGES; 3.2 Change the password verification method for the connection The encryption method of MySQL8.X is caching_sha2_password. The caching_sha2_password encryption method is not supported during remote access, so it needs to be changed to: # a. Modify the specified user ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; # b. Be sure to refresh the permissions (reload), otherwise you need to restart MySQL to take effect FLUSH PRIVILEGES; 4. Import data into the new MySQLTo import data, I first copy the database backup file into the new Docker, and then execute the import command. The command is as follows: #Copy the backup file to docker cp /root/all-databases3306.sql 3sfsdf:/root/all-databases3306.sql #First enter the docker environment, then import it into the database docker exec -it xxx /bin/bash mysql -u root -p < /root/all-databases3306.sql 5. Reference Documents https://hub.docker.com/r/mysql/mysql-server/ Summarize The above is the editor's introduction to the upgrade of Docker version of MySQL5.7 to MySQL8.0.13 and data migration. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Summary of how to modify the root password in MySQL 5.7 and MySQL 8.0
>>: Example steps for using AntV X6 with Vue.js
Today I found that WordPress could not connect to...
need: The official website's resource server ...
This article explains how to install MySQL from a...
Table of contents Preface difficulty Cross-domain...
Preliminary Notes 1.Differences between Vue2.x an...
Table of contents 1. Understanding the Equality R...
1 Download and start Tomcat Go to the official we...
Table of contents summary Overall process front e...
Say goodbye to the past Before vscode had remote ...
First of all, I don't know why I can't lo...
1: masterha_check_repl replica set error replicat...
The custom encapsulation code of the vue button c...
Table of contents 1. Install node 2. Install Comm...
1. Tools We need two tools now: MySQL server (mys...
Xiaobai records the installation of vmtools: 1. S...