Recently, the MySQL of the test environment needs to be upgraded from 5.6 to 5.7.
I first set up an Ubuntu14 virtual machine to simulate the upgrade.
Started various pit records
This scheme can be skipped, it is all pits.
Search for Ubuntu14 MySQL Upgrade 5.7
, there are many results
After checking, I found that the processing methods are all the same. Since everyone is upgrading like this, there must be a problem. I believe it
sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.1-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.1-1_all.deb
Choose MySQL5.7
sudo apt update
Reported an error,
Find a solution, as follows
apt-key list //View all signatures,An expired signature was found
apt-key del 5072E1F5 //Delete expired signature//Reimport signature
apt-key adv --keyserver pgp.mit.edu --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5
//Execute again
apt update
apt install mysql-server
Then there are all kinds of error reporting trips, I will not count them one by one.
During the period from 9 o'clock last night to 1 o'clock in the morning, and then from 9 o'clock in the morning to 5 o'clock in the afternoon. I reset the virtual machine used for the test M times, encountered N problems, and solved N-1 problems.
In the end, I gave up. It was all lie.
The update fails, I can always reinstall it.
Backup database data
The utf8mb4 encoding is used here because emoji exists in the database
mysqldump -u root -p --default-character-set=utf8mb4 --all-databases > sql.sql
The backup database file is best to find a test 5.7 and import it to prevent problems
Backup configuration file
sudo tar zcvf mysql_config.tar.gz /etc/mysql/
View installed MySQL
dpkg -l | grep mysql
Uninstallation steps:
Recheck if there is still mysql related
dpkg -l | grep mysql
If the uninstallation is not complete, execute dpkg -l |grep ^rc|awk'{print $2}' |sudo xargs dpkg -P
to clean up residual mysql files
# Download tar,Use domestic mirror,Will be faster
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-server_5.7.25-1ubuntu14.04_amd64.deb-bundle.tar
# unzip
tar -xvf mysql-server_5.7.25-1ubuntu14.04_amd64.deb-bundle.tar
# start installation
sudo apt update
sudo dpkg -i mysql-common_5.7.25-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.25-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.7.25-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.7.25-1ubuntu14.04_amd64.deb
# The following step requires dependency
sudo apt install libaio1
sudo dpkg -i mysql-community-client_5.7.25-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-client_5.7.25-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-source_5.7.25-1ubuntu14.04_amd64.deb
# Installation dependencies
sudo apt install libmecab2
# This step will ask you to enter the password of the root user of the database
# The password entered here must be the same as the original one,Because the data will be restored later,Password will overwrite
sudo dpkg -i mysql-community-server_5.7.25-1ubuntu14.04_amd64.deb
Installation is complete, try to log in
service mysql start
# Version is 5.7,correct
mysql -u root -p
The installation is complete!!!
# The first database file backed up
mysql -u root -p < sql.sql
Refer to the original configuration file, modify the current configuration file
I also stepped on a lot of pits during uninstallation and installation.The above steps are what I can finally use after experiments.
I have tested the above steps on the virtual machine for nearly 20 times, it should be a problem. Next, I can move the test environment. Let’s move on tomorrow, goodbye!!!
Recommended Posts