MySQL version updated from 5.7.37 to 5.7.39

1. Prospects

Because mysql5.7.37 has loopholes that affect system security, it is necessary to upgrade the mysql version to the latest version 5.7.39 of 5.7.

Two, steps

1. Download the installation package of 5.7.39:

The download link is as follows:

https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.39-1.el7.x86_64.rpm-bundle.tar

2. Unzip the installation package

tar -xvf   mysql-5.7.39-1.el7.x86_64.rpm-bundle.tar

3. View the startup command of the previous version

Since the previous version may not be installed by ourselves, we need to check the startup command to facilitate the execution of the fourth step

history|grep start

The startup command of a version of mysql on my machine is:

/etc/init.d/mysqld start

4. Stop the mysql service of the previous version

/etc/init.d/mysqld stop

Note: Each of you has a different start command, so you need to replace it with your own stop command

5. Backup configuration files

cp /etc/my.cnf /etc/my.cnf20230112

Note: Everyone's configuration file is different, you need to replace it with the path of your own configuration file

6. Backup data

(1) Back up the mysqld file

cp /etc/init.d/mysqld  /root/mysqld20230112

Note: Do not back up to the same directory when backing up

(2) Back up the data directory of mysql

tar -zcvf mysqldata.tar.gz /data/mysql
tar -zcvf mysqlsoftware.tar.gz /software/mysql

7. Install the new version of Mysql5.7.39

cd   /data/5.7.39
rpm -Uvh *.rpm

Note: (1) You can also use the following command to install

rpm -ivh *.rpm

(2) The following errors may be reported during installation

First delete the package in the red box below

Execute the command rpm -qa mariadb-libs to check whether mariadb-libs is installed

rpm -qa mariadb-libs

Found the installed mariadb-libs, so you need to uninstall mariadb-libs and reinstall

The uninstall command is as follows:

rpm -e mariadb-libs-5.5.52-1.el7.x86_64

If an error is found, execute the following command to force uninstall

rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

Re-execute rpm -qa mariadb-libs to see if the uninstallation is successful

rpm -qa mariadb-libs

8. Change the configuration file

Check whether the configuration file is consistent with the content before backup. If it is consistent, start it. If it is inconsistent, copy the configuration in the backup file to the newly generated my.cnf

Delete newly generated configuration files

Use the original configuration file

9. Delete the original mysqld file

rm -rf /etc/init.d/mysqld

10. Start the mysql file

systemctl start mysqld

11. Check the startup status

systemctl status mysqld

verify now

Guess you like

Origin blog.csdn.net/wd520521/article/details/128675579