Types of MySQL Version Upgrades

there are two types of upgrades

  1. Minor MySQL Version Upgrade
    • Example : upgrade from 8.0.28 to 8.0.30
  2. Major MySQL Version Upgrade
    • Example : upgrade from 5.7 to 8.0

Minor Version Upgrade

The first step when performing a minor version upgrade is to obtain the current version of MySQL and the newer minor upgrade available.

To get the current version of MySQL on Red Hat, we use the following command, which queries the RPM package:


rpm -qa | grep -i percona

To obtain the newer version, we can check the Percona website and see which is the latest version released.

https://www.percona.com/downloads

To summarize our current setup, we are running Percona MySQL 8.0.30 and aiming to upgrade it to version 8.0.35

To begin, we will obtain the new version for Percona Server and Percona Server Client from the Percona website. We can directly download the packages using the wget command.

i will copy the link for download and past it along side wget command to download the package on VM

wget https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.35-27/binary/redhat/8/x86_64/percona-server-client-8.0.35-27.1.el8.x86_64.rpm?_gl=1*14grt98*_gcl_au*MTA0Mzk1MDYyOS4xNzE1NjkwMzk5

wget  https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.35-27/binary/redhat/8/x86_64/percona-server-server-8.0.35-27.1.el8.x86_64.rpm?_gl=1*14grt98*_gcl_au*MTA0Mzk1MDYyOS4xNzE1NjkwMzk5

the file will be download compressed in at format , we will use command tar -xf [filename] to extract the file

tar -xf percona-server-client-8.0.35-27.1.el8.aarch64.rpm?_gl=1*1p3zum3*_gcl_au*MTA0Mzk1MDYyOS4xNzE1NjkwMzk5


 tar -xf percona-server-server-8.0.35-27.1.el8.x86_64.rpm?_gl=1*14grt98*_gcl_au*MTA0Mzk1MDYyOS4xNzE1NjkwMzk5


next step which is very important is to stop MySQL services


systemctl stop mysqld

systemctl status mysqld

now we will start installing the package using yum localinstall


sudo yum localinstall percona-server-client-8.0.35-27.1.el8.x86_64.rpm


The minor upgrade has completed successfully, and we can now start the MySQL service.

Major MySQL Version Upgrade

reference link
For a MySQL major version upgrade, the process typically involves installing the desired major version first, such as MySQL 5.7, and then performing the upgrade to version 8.

we can use the below script to install MySQL 5.8

PERCONA REPO
sudo yum -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
ENABLE 5.7 REPO
sudo percona-release setup ps57
INSTALL MYSQL 5.7
sudo yum -y install Percona-Server-server-57
VERIFY MYSQL 5.7
rpm -qa | grep -i percona
START MYSQL
sudo systemctl start mysqld.service
GRAB ROOT PASSWORD AND RUN SECURE INSTALLATION
grep temp /var/log/mysqld.log
mysql_secure_installation




For testing purposes, we’ll replicate the real-world example database on the server to simulate the upgrade in a more realistic manner. You can execute the following command to download the database and then import it into the MySQL server.

wget https://downloads.mysql.com/docs/world-db.tar.gz

tar -xf world-db.tar.gz


cd  world-db/
mysql -uroot -p < world.sql

1- MySQL upgrade checklist

first thing we need to confirm that all the data in the database and all tables are in proper format

we can use the mysqlcheck utility


mysqlcheck -uroot -p --all-databases --check-upgrade

The command will verify all tables in the database to ensure their compliance with the current version, checking for any errors or inconsistencies.

2- mysqlsh script – Pre-Upgrade Check

There is actually a MySQL script, designed by Oracle, that checks whether the current version is compatible with the MySQL upgrade process.

you can follow the steps in this link You’ll download MySQL Shell and run a script that assesses whether upgrading from the current version to MySQL 8 is feasible.

mysqlsh is installed and now we will run the script provided by oracle to check upgrade combability

 mysqlsh -- util check-for-server-upgrade root@localhost --target-version=8.0.30 --output-format=JSON --config-path=/etc/my.cnf

The concern is ensuring that the report generated by the script does not contain any errors.
you may receive a warning regarding mysql_native_authenticating which will be deprecated in newer MySQL versions, so keep this in mind and make sure that the MySQLl server you want to upgrade does support mysql_native_sql, otherwise you will have to change the user to authenticate via caching_sha2_password

3- Dumping the Database

It is highly recommended to create a full database dump before you perform any upgrade. This guarantees that you have a backup of your data in case something goes wrong during the upgrade process and you need to restore it.

To create a database dump, you can use the mysqldump utility. Here’s an example command:

mysqldump -u root -p --all-databases > all_databases.sql

This command will create a file named all_databases.sql that contains a dump of all databases on the server.”””

Perform MySQL Major Version Upgrade

now we will start by downloading the mysql package
but before that let’s first verify which package are installed
rpm -qa | grep -i percona

we will download the package first

wget https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.30-22/binary/redhat/8/x86_64/Percona-Server-8.0.30-22-r7e301439b65-el8-x86_64-bundle.tar?_gl=1*1hchtzx*_gcl_au*MTA0Mzk1MDYyOS4xNzE1NjkwMzk5


tar -xf Percona-Server-8.0.30-22-r7e301439b65-el8-x86_64-bundle.tar?_gl=1*1hchtzx*_gcl_au*MTA0Mzk1MDYyOS4xNzE1NjkwMzk

now stop mysqld services

systemctl stop mysqld


remove MySQL 5.7 from system

 sudo yum remove Percona-Server-shared-compat-57-5.7.44-48.1.el8.x86_64 -y

sudo yum remove Percona-Server-shared-57-5.7.44-48.1.el8.x86_64

Removing ‘shared’ and ‘shared-compat’ will uninstall both the MySQL Server client and the MySQL Server itself.

now we will install mysql 8 on system

sudo yum localinstall  percona-server-shared-8.0.30-22.1.el8.x86_64.rpm

sudo yum localinstall  percona-server-shared-8.0.30-22.1.el8.x86_64.rpm

sudo yum localinstall percona-icu-data-files-8.0.30-22.1.el8.x86_64.rpm

sudo yum  localinstall percona-server-client-8.0.30-22.1.el8.x86_64.rpm


sudo yum  localinstall percona-server-server-8.0.30-22.1.el8.x86_64.rpm

Before initiating the upgrade process, you need to start MySQL with the upgrade option. Upon starting mysqld with the upgrade option, from version shared-8.0.16 onwards, it will conduct a check on all binary and data files, initiating the upgrade process as necessary.

systemctl start mysqld

You can monitor the progress of the upgrade process by checking the log files, which will provide insights into how the upgrade process is proceeding.


sudo cat /var/log/mysqld.log