# MySQL Upgrade from 8.0.4 to 8.4.x (RHEL) Internet

This article describes the steps, checks, and dependencies required to upgrade MySQL from version 8.0.4 to 8.4.x on RHEL 8 systems. It covers prerequisites, pre-upgrade tasks, upgrade execution, post-upgrade validations, and rollback procedures to ensure a safe and reliable production upgrade.

### Prerequisites

#### **OS Compatibility**

* Verify that the operating system supports MySQL 8.4.
* Recommended: RHEL 8.x or later.
* Check the OS version:

  ```bash
  cat /etc/os-release
  ```

#### **System Requirements**

* Ensure sufficient disk space for backup and rollback (`df -Th`).
* Confirm root or sudo access.
* All listed commands must be executed.

## Pre-Upgrade Checks

### **Backup**

* Perform a logical backup of the MySQL database.
* **Log Management Procedure**
* Confirm you are backing up the correct schema.

  ```bash
  mkdir /home/ec2-user/mysql_backup  
  mysqldump -u root -p ovaledgedb > /home/ec2-user/mysql_backup/ovaledgedb_backup.sql
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2Fh61eJYvimDVrypXBmzjH%2Fimage.png?alt=media&#x26;token=590480d1-8c34-40dd-957e-9a6624f018a7" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Ensure sufficient space is available before running the `mysqldump` command.
{% endhint %}

* **Back up configuration files:**

  ```bash
  sudo cp /etc/my.cnf /home/ec2-user/mysql_backup/  
  sudo cp -a /var/lib/mysql /home/ec2-user/mysql_backup/
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2Fubg5S0pBO31woFNxFGVV%2Fimage.png?alt=media&#x26;token=f503a29d-9392-47e8-b5ee-547577d5a562" alt=""><figcaption></figcaption></figure>

**Database Size and Row Count Check**

* Run the following queries before upgrading:

  **Database size query:**

  ```sql
  SELECT 
      table_schema AS "Database Name", 
      ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS "DB Size (MB)"
  FROM information_schema.tables 
  GROUP BY table_schema;
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FI4Jou9d96YfiX5LEgjkL%2Fimage.png?alt=media&#x26;token=3d3e415c-6290-4ccf-9095-422439951133" alt=""><figcaption></figcaption></figure>

  **Row count query:**\
  \&#xNAN;*(*[*Download SQL script*](https://ovaledge.s3.us-west-1.amazonaws.com/queries/dbsize.sql?utm_source=chatgpt.com)*)*

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FWIs7akiyztqzZlIgXzX8%2Fimage.png?alt=media&#x26;token=c53b70f5-0612-4317-a29d-9acdee8ac00b" alt=""><figcaption></figcaption></figure>
* Save outputs for post-upgrade comparison.

## Upgrade Execution

### **Stop MySQL Services**

Stop MySQL services by running the following command

<figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FSogKlmD8YlANBMYk1PqS%2Fimage.png?alt=media&#x26;token=249b9550-0244-4ae0-add7-aae6753c4ab8" alt=""><figcaption></figcaption></figure>

```bash
mysql --version  
sudo systemctl stop mysqld
```

### **Install MySQL 8.4.x**

* **Download repository package:**

  ```bash
  wget https://dev.mysql.com/get/mysql84-community-release-el8-1.noarch.rpm
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FPOje3xkPXchHFPwveLmJ%2Fimage.png?alt=media&#x26;token=04762d51-d990-4433-a0c9-083806c1389b" alt=""><figcaption></figcaption></figure>
* **Install repository:**

  ```bash
  sudo yum localinstall mysql84-community-release-el8-1.noarch.rpm
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FWcSzDFs3Q7piy873i9yr%2Fimage.png?alt=media&#x26;token=f12ffad3-f74c-4389-939e-e562d9ea53b5" alt=""><figcaption></figcaption></figure>
* Disable any existing MySQL 8.0 repositories:

  ```bash
  sudo vi /etc/yum.repos.d/mysql-community.repo
  # enable=0 (disable) / enable=1 (enabled)
  ```
* Disable MySQL module in the package manager:

  ```bash
  sudo yum module disable mysql -y
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FipmWioSoKu8QdHL0zP9e%2Fimage.png?alt=media&#x26;token=0e5b7bc2-ad05-4290-aa76-4b93beed2006" alt=""><figcaption></figcaption></figure>
* Install MySQL 8.4.x:

  ```bash
  sudo yum install mysql-community-server
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FIzCpIg3h921gg7pk4e2o%2Fimage.png?alt=media&#x26;token=d05607e3-b0da-4ca9-abaf-c78ee84fc43c" alt=""><figcaption></figcaption></figure>
* Check installed version:

  ```bash
  mysql --version
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2F1dZtjcGD4t1XmfpIvPOs%2Fimage.png?alt=media&#x26;token=ba4c029c-5005-42d2-9bf7-8b5a78c59944" alt=""><figcaption></figcaption></figure>

**Update Configuration**

* Edit the configuration file:

  ```bash
  sudo vi /etc/my.cnf
  mysql_native_password=ON
  ```
* Save file and restart MySQL:

  ```bash
  sudo systemctl restart mysqld  
  sudo systemctl status mysqld
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FTxhmPrFwRx6m9EQoWQbe%2Fimage.png?alt=media&#x26;token=b86f59f7-fc1b-4a17-a885-44ed3c4fd6f5" alt=""><figcaption></figcaption></figure>
* Verify upgrade by checking MySQL version.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FFlCE1KHT8OuuWtBpKFCx%2Fimage.png?alt=media&#x26;token=a6ae9845-013c-44c3-9513-b29f02cfa2a8" alt=""><figcaption></figcaption></figure>

## Post-Upgrade Validations

### **Verify Row Counts and Database Size**

* Connect to MySQL:

  ```bash
  mysql -u root -p
  ```
* Run validation queries:
  * Row count query: [SQL Script](https://ovaledge.s3.us-west-1.amazonaws.com/queries/dbsize.sql)<br>

    <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2F3DHbSfeUS6WBeD6pXNFf%2Fimage.png?alt=media&#x26;token=8a728ad1-a141-488b-a5b9-7fbee13183c6" alt=""><figcaption></figcaption></figure>
  * Database size query:

    ```sql
    SELECT 
        table_schema AS "Database Name", 
        ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS "DB Size (MB)"
    FROM information_schema.tables 
    GROUP BY table_schema;
    ```

    <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FOIZve1vsQe7NXKEZWMaF%2Fimage.png?alt=media&#x26;token=e1bcdf7c-fc78-45d1-a492-f5cb9fee9fa9" alt=""><figcaption></figcaption></figure>
* Compare results with pre-upgrade outputs.

**Update MySQL Parameters**

* Add/update parameters in `/etc/my.cnf`:

  ```
  max_binlog_size=1GB
  binlog_expire_logs_seconds=2592000
  group_concat_max_len=50000
  max_connections=600
  innodb_buffer_pool_size=10GB
  max_allowed_packet=1G
  bind-address=0.0.0.0
  ```
* Adjust values as per client instance size.<br>

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FWfjdJcqPeqqlhEiVVYS5%2Fimage.png?alt=media&#x26;token=082e8fbc-024d-4e99-a737-e87ec85b4cbe" alt=""><figcaption></figcaption></figure>
* Restart MySQL:

  ```bash
  sudo systemctl restart mysqld
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FzcbP2OXPGmbRrbidwrWo%2Fimage.png?alt=media&#x26;token=25c201a4-e371-4305-88ba-1d76f66255d5" alt=""><figcaption></figcaption></figure>

### **Update Application User Passwords (Optional)**

* Change OvalEdge MySQL user passwords:

  ```sql
  ALTER USER 'ovaledge'@'localhost' IDENTIFIED BY '<Password>';  
  ALTER USER 'ovaledge'@'%' IDENTIFIED BY '<Password>';  
  FLUSH PRIVILEGES;
  ```

At this stage, the MySQL database has been upgraded to version 8.4 and the default OvalEdge MySQL password has been changed.

### Rollback Plan (if required)

* Take backup of MySQL 8.4 installation before rollback:

  ```bash
  mkdir /home/ec2-user/mysql8.4_backup  
  sudo cp /etc/my.cnf /home/ec2-user/mysql8.4_backup  
  sudo cp -a /var/lib/mysql /home/ec2-user/mysql8.4_backup
  ```
* Stop MySQL services, reinstall MySQL 8.0.4, start the service, and restore data from backups.

***

Copyright © 2025, OvalEdge LLC, Peachtree Corners, GA, USA.
