Sriram Sanka – My Experiences with Databases & More

Oracle-MySQL-SQL SERVER-Python-Azure-AWS-Oracle Cloud-GCP etc

  • Enter your email address to follow this blog and receive notifications of new posts by email.

  • Total Views

    • 588,482 hits
  • $riram $anka


    The experiences, Test cases, views, and opinions etc expressed in this website are my own and does not reflect the views or opinions of my employer. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content.Product and company names mentioned in this website may be the trademarks of their respective owners.

Upgrade MySQL Server from 5.7 to 8 CentOS 7 Linux

Posted by Sriram Sanka on October 2, 2022


Quote from Mysql Website Upgrade Paths

  • Upgrade from MySQL 5.7 to 8.0 is supported. However, upgrade is only supported between General Availability (GA) releases. For MySQL 8.0, it is required that you upgrade from a MySQL 5.7 GA release (5.7.9 or higher). Upgrades from non-GA releases of MySQL 5.7 are not supported.
  • Upgrading to the latest release is recommended before upgrading to the next version. For example, upgrade to the latest MySQL 5.7 release before upgrading to MySQL 8.0.
  • Upgrade that skips versions is not supported. For example, upgrading directly from MySQL 5.6 to 8.0 is not supported.
  • Once a release series reaches General Availability (GA) status, upgrade within the release series (from one GA version to another GA version) is supported. For example, upgrading from MySQL 8.0.x to 8.0.y is supported. (Upgrade involving development-status non-GA releases is not supported.) Skipping a release is also supported. For example, upgrading from MySQL 8.0.x to 8.0.z is supported. MySQL 8.0.11 is the first GA status release within the MySQL 8.0 release series.

Reference: https://dev.mysql.com/doc/refman/8.0/en/upgrade-paths.html

Download the Required RPM and place them in the Server.

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.30-1.el7.x86_64.rpm-bundle.tar

Take the Backup of all the Databases and stop the MySQL Service.

Run the Following from Local Directory using yum localinstall mysql-community-{server,client,common,libs}-*

yum localinstall mysql-community-{server,client,common,libs}-*
[root@localhost mysql_binaries]# yum localinstall mysql-community-{server,client,common,libs}-*
Loaded plugins: fastestmirror, langpacks
Examining mysql-community-server-8.0.30-1.el7.x86_64.rpm: mysql-community-server-8.0.30-1.el7.x86_64
Marking mysql-community-server-8.0.30-1.el7.x86_64.rpm as an update to mysql-community-server-5.7.9-1.el7.x86_64
Examining mysql-community-server-debug-8.0.30-1.el7.x86_64.rpm: mysql-community-server-debug-8.0.30-1.el7.x86_64
Marking mysql-community-server-debug-8.0.30-1.el7.x86_64.rpm to be installed
Examining mysql-community-client-8.0.30-1.el7.x86_64.rpm: mysql-community-client-8.0.30-1.el7.x86_64
Marking mysql-community-client-8.0.30-1.el7.x86_64.rpm as an update to mysql-community-client-5.7.9-1.el7.x86_64
Examining mysql-community-client-plugins-8.0.30-1.el7.x86_64.rpm: mysql-community-client-plugins-8.0.30-1.el7.x86_64
Marking mysql-community-client-plugins-8.0.30-1.el7.x86_64.rpm to be installed
Examining mysql-community-common-8.0.30-1.el7.x86_64.rpm: mysql-community-common-8.0.30-1.el7.x86_64
Marking mysql-community-common-8.0.30-1.el7.x86_64.rpm as an update to mysql-community-common-5.7.9-1.el7.x86_64
Examining mysql-community-libs-8.0.30-1.el7.x86_64.rpm: mysql-community-libs-8.0.30-1.el7.x86_64
Marking mysql-community-libs-8.0.30-1.el7.x86_64.rpm as an update to mysql-community-libs-5.7.9-1.el7.x86_64
Examining mysql-community-libs-compat-8.0.30-1.el7.x86_64.rpm: mysql-community-libs-compat-8.0.30-1.el7.x86_64
Marking mysql-community-libs-compat-8.0.30-1.el7.x86_64.rpm as an update to mysql-community-libs-compat-5.7.9-1.el7.x86_64
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.9-1.el7 will be updated
---> Package mysql-community-client.x86_64 0:8.0.30-1.el7 will be an update
---> Package mysql-community-client-plugins.x86_64 0:8.0.30-1.el7 will be installed
---> Package mysql-community-common.x86_64 0:5.7.9-1.el7 will be updated
---> Package mysql-community-common.x86_64 0:8.0.30-1.el7 will be an update
---> Package mysql-community-libs.x86_64 0:5.7.9-1.el7 will be updated
---> Package mysql-community-libs.x86_64 0:8.0.30-1.el7 will be an update
---> Package mysql-community-libs-compat.x86_64 0:5.7.9-1.el7 will be updated
---> Package mysql-community-libs-compat.x86_64 0:8.0.30-1.el7 will be an update
---> Package mysql-community-server.x86_64 0:5.7.9-1.el7 will be updated
---> Package mysql-community-server.x86_64 0:8.0.30-1.el7 will be an update
---> Package mysql-community-server-debug.x86_64 0:8.0.30-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================================================================
 Package                                                       Arch                                  Version                                        Repository                                                                          Size
=============================================================================================================================================================================================================================================
Installing:
 mysql-community-client-plugins                                x86_64                                8.0.30-1.el7                                   /mysql-community-client-plugins-8.0.30-1.el7.x86_64                                 14 M
 mysql-community-server-debug                                  x86_64                                8.0.30-1.el7                                   /mysql-community-server-debug-8.0.30-1.el7.x86_64                                  115 M
Updating:
 mysql-community-client                                        x86_64                                8.0.30-1.el7                                   /mysql-community-client-8.0.30-1.el7.x86_64                                         71 M
 mysql-community-common                                        x86_64                                8.0.30-1.el7                                   /mysql-community-common-8.0.30-1.el7.x86_64                                        9.9 M
 mysql-community-libs                                          x86_64                                8.0.30-1.el7                                   /mysql-community-libs-8.0.30-1.el7.x86_64                                          7.6 M
 mysql-community-libs-compat                                   x86_64                                8.0.30-1.el7                                   /mysql-community-libs-compat-8.0.30-1.el7.x86_64                                   3.7 M
 mysql-community-server                                        x86_64                                8.0.30-1.el7                                   /mysql-community-server-8.0.30-1.el7.x86_64                                        241 M

Transaction Summary
=============================================================================================================================================================================================================================================
Install  2 Packages
Upgrade  5 Packages

Total size: 462 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-client-plugins-8.0.30-1.el7.x86_64                                                                                                                                                                       1/12
  Updating   : mysql-community-common-8.0.30-1.el7.x86_64                                                                                                                                                                               2/12
  Updating   : mysql-community-libs-8.0.30-1.el7.x86_64                                                                                                                                                                                 3/12
  Updating   : mysql-community-client-8.0.30-1.el7.x86_64                                                                                                                                                                               4/12
  Updating   : mysql-community-server-8.0.30-1.el7.x86_64                                                                                                                                                                               5/12
  Installing : mysql-community-server-debug-8.0.30-1.el7.x86_64                                                                                                                                                                         6/12
  Updating   : mysql-community-libs-compat-8.0.30-1.el7.x86_64                                                                                                                                                                          7/12
  Cleanup    : mysql-community-server-5.7.9-1.el7.x86_64                                                                                                                                                                                8/12
  Cleanup    : mysql-community-client-5.7.9-1.el7.x86_64                                                                                                                                                                                9/12
  Cleanup    : mysql-community-libs-compat-5.7.9-1.el7.x86_64                                                                                                                                                                          10/12
  Cleanup    : mysql-community-libs-5.7.9-1.el7.x86_64                                                                                                                                                                                 11/12
  Cleanup    : mysql-community-common-5.7.9-1.el7.x86_64                                                                                                                                                                               12/12
  Verifying  : mysql-community-common-8.0.30-1.el7.x86_64                                                                                                                                                                               1/12
  Verifying  : mysql-community-client-plugins-8.0.30-1.el7.x86_64                                                                                                                                                                       2/12
  Verifying  : mysql-community-libs-8.0.30-1.el7.x86_64                                                                                                                                                                                 3/12
  Verifying  : mysql-community-client-8.0.30-1.el7.x86_64                                                                                                                                                                               4/12
  Verifying  : mysql-community-libs-compat-8.0.30-1.el7.x86_64                                                                                                                                                                          5/12
  Verifying  : mysql-community-server-8.0.30-1.el7.x86_64                                                                                                                                                                               6/12
  Verifying  : mysql-community-server-debug-8.0.30-1.el7.x86_64                                                                                                                                                                         7/12
  Verifying  : mysql-community-client-5.7.9-1.el7.x86_64                                                                                                                                                                                8/12
  Verifying  : mysql-community-libs-5.7.9-1.el7.x86_64                                                                                                                                                                                  9/12
  Verifying  : mysql-community-server-5.7.9-1.el7.x86_64                                                                                                                                                                               10/12
  Verifying  : mysql-community-common-5.7.9-1.el7.x86_64                                                                                                                                                                               11/12
  Verifying  : mysql-community-libs-compat-5.7.9-1.el7.x86_64                                                                                                                                                                          12/12

Installed:
  mysql-community-client-plugins.x86_64 0:8.0.30-1.el7                                                                   mysql-community-server-debug.x86_64 0:8.0.30-1.el7

Updated:
  mysql-community-client.x86_64 0:8.0.30-1.el7  mysql-community-common.x86_64 0:8.0.30-1.el7  mysql-community-libs.x86_64 0:8.0.30-1.el7  mysql-community-libs-compat.x86_64 0:8.0.30-1.el7  mysql-community-server.x86_64 0:8.0.30-1.el7

Complete!

This completes the Upgrade from 5.7 to 8.0(Or Latest) Start the Service again and verify.

[root@localhost mysql_binaries]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@localhost mysql_binaries]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-10-02 03:54:08 EDT; 4s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 21468 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 21502 (mysqld)
   Status: "Server is operational"
    Tasks: 39
   CGroup: /system.slice/mysqld.service
           └─21502 /usr/sbin/mysqld

Oct 02 03:53:16 localhost.localdomain systemd[1]: Starting MySQL Server...
Oct 02 03:54:08 localhost.localdomain systemd[1]: Started MySQL Server.
Note You can also use rpm -Uvh *.rpm to upgrade the Version.

Connect to the Database and verify if there are any errors.

[root@localhost mysql_binaries]# mysql -uroot -p************
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.30 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sriram             |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> use sriram;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+------------------+
| Tables_in_sriram |
+------------------+
| sriram_table     |
+------------------+
1 row in set (0.01 sec)

mysql> select * from sriram_table;
+------+---------+
| id   | name    |
+------+---------+
|    1 | Sriram  |
|    2 | Sriram2 |
|    3 | Sriram3 |
+------+---------+
3 rows in set (0.00 sec)

mysql> show variables like '%version%';
+--------------------------+------------------------------+
| Variable_name            | Value                        |
+--------------------------+------------------------------+
| admin_tls_version        | TLSv1.2                      |
| immediate_server_version | 999999                       |
| innodb_version           | 8.0.30                       |
| original_server_version  | 999999                       |
| protocol_version         | 10                           |
| replica_type_conversions |                              |
| slave_type_conversions   |                              |
| tls_version              | TLSv1.2                      |
| version                  | 8.0.30                       |
| version_comment          | MySQL Community Server - GPL |
| version_compile_machine  | x86_64                       |
| version_compile_os       | Linux                        |
| version_compile_zlib     | 1.2.12                       |
+--------------------------+------------------------------+
13 rows in set (0.00 sec)

mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.30    |
+-----------+
1 row in set (0.00 sec)

mysql>

Since Mysql_upgrade is deprecated and unneeded in Version 8.0.16 and later, you can run mysql_check if needed.

[root@localhost mysql_binaries]# mysql_upgrade -uroot -p
The mysql_upgrade client is now deprecated. The actions executed by the upgrade client are now done by the server.
To upgrade, please start the new MySQL binary with the older data directory. Repairing user tables is done automatically. Restart is not required after upgrade.
The upgrade process automatically starts on running a new MySQL binary with an older data directory. To avoid accidental upgrades, please use the --upgrade=NONE option with the MySQL binary. The option --upgrade=FORCE is also provided to run the server upgrade sequence on demand.
It may be possible that the server upgrade fails due to a number of reasons. In that case, the upgrade sequence will run again during the next MySQL server start. If the server upgrade fails repeatedly, the server can be started with the --upgrade=MINIMAL option to start the server without executing the upgrade sequence, thus allowing users to manually rectify the problem.

Option 2: Follow the Below steps to Complete the Upgrade Steps

Take a backup of all the Databases & Parameter /Variable Values assigned.

Stop the Service.

Remove the Installed Old Version RPM by running rpm -qa mysql* and rpm -e <RPM_LIST>

Install the Latest Version

Restore the Backup from above

Add and Apply variable as before as supported

Conclusion : We have successfully completed the MySQL Community Server Version Upgrade on a standalone Server from 5.7 to 8.0.30

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.