In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you how to upgrade MySQL 5.7 to MySQL 8.0.13 in Docker. The content is simple and easy to understand. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "How to upgrade MySQL 5.7 to MySQL 8.0.13 in Docker".
1. Backup old MySQL 5.7 data
Remember to back up old data first to prevent data loss due to upgrade failure. There are two ways to backup, one is to directly execute the export command on the host machine, and the other is to enter the Docker environment first. The main export commands are as follows:
#Method 1: backup data directly on the host machine #0ddf568 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, exported sql to/root/all-databases3306.sqldocker exec -it 0df568 mysqldump -uroot -p123456 --databases dbA dbB > /root/all-databases3306.sql#============================================================= Then copy the exported sql to the host #First enter dockerdocker exec -it 0df568 /bin/bash#Optional source /etc/profile#Execute export command mysqldump -uroot -p123456 --databases dbA dbB > /root/all-databases3306.sql#Copy to host #Exit Docker, execute exit command exit#At this time, you are already in the host environment, execute copy command, copy sql file from docker red docker cp 0df568:/root/all-databases3306.sql/root/all-databases3306.sql 2. Pull the image of MySQL 8.0.13 and complete the installation.
Pull and install MySQL can actually refer to the official website. Please refer to hub.docker.com/r/mysql/mysql-server/ for a brief description of the installation process.
2.1 Pull mirror to local
Run 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, you want MySQL 8.0.13, then tag is 8.0.13, then execute: docker pull mysql/mysql-server:8.0.13
docker pull mysql/mysql-server:tag
You can use docker images to see what you pulled down.
2.2 Run MySQL 8.0.13 mirror
Run the specified Docker image of MySQL 8.0.13. We have pulled the specified image down in step 2.1, so you can view the local Docker image through docker images and get the ID and name of the image. Next, run the following command to run the Docker image of MySQL 8.0.13:
#--name Specifies the name of the startup-e Specifies the environment variable in docker-v partition or directory mapping, docker program data maps to the specified location of the host-p Specifies the port mapping of the host to 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 ps3. Some problems after upgrading to MySQL 8.X
After 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 provide remote access
Change the user to @'%', % means all hosts can be connected, command as follows:
#root into the database and execute the following command #a. use mysql;#b. then execute GRANT ALL privies on. TO 'root'@'%' IDENTIFIED BY '123456'#c. Be sure to refresh permissions (reload), otherwise you need to restart MySQL to take effect FLUSH PRIVILEGES;3.2 Change the password verification method for connections
MySQL8.X encryption method is caching_sha2_password, caching_sha2_password encryption method is not supported in remote access, so you need to change: mysql_native_password
# a. Modify the specified user ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';# b. Be sure to refresh permissions (reload), otherwise you need to restart MySQL to take effect FLUSH PRIVILEGES;4. Import data into new MySQL
To import data, I copy the database backup file into the new Docker and then execute the import command. The order reads as follows:
#Copy backup files to docker docker cp/root/all-databases3306.sql 3sfsdf:/root/all-databases3306.sql #Enter docker environment first, then import to database docker exec -it xxx /bin/bashmysql -u root -p < /root/all-databases3306.sql The above is "How to upgrade MySQL 5.7 to MySQL 8.0.13 in Docker" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.