# 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="/files/oqACLhSCm1eARR6Npj0i" 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="/files/RZU0JfcJaREC1znrTnWK" 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="/files/kM2BRCEi01jq6le1PJmE" 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="/files/IP93UTEzENHUWK2AYtRQ" 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="/files/2skJX28lqr9nKiodK7UD" 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="/files/IFvMJT72gfdXOBwk70mK" alt=""><figcaption></figcaption></figure>
* **Install repository:**

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

  <figure><img src="/files/aXUeawoSum2ar1TWMzbI" 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="/files/o6vas48FyJXmWdrVebul" alt=""><figcaption></figcaption></figure>
* Install MySQL 8.4.x:

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

  <figure><img src="/files/LrP0JtAOYN8S152htRBm" alt=""><figcaption></figcaption></figure>
* Check installed version:

  ```bash
  mysql --version
  ```

  <figure><img src="/files/vFuh7zV2jHgEfnFe9zyS" 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="/files/gjRURZRCrqaU1VZZvZY8" alt=""><figcaption></figcaption></figure>
* Verify upgrade by checking MySQL version.

  <figure><img src="/files/5MmsYzrdcyj2G5TA2ykJ" 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="/files/UgcItVnNwRA2xtIV0Xu4" 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="/files/J0wRSBiEISiHaxO52pwx" 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="/files/W4WC9JhcalOsuFb2Dc20" alt=""><figcaption></figcaption></figure>
* Restart MySQL:

  ```bash
  sudo systemctl restart mysqld
  ```

  <figure><img src="/files/5r4rpt3fX8Nznelu6phU" 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ovaledge.com/release8.1/deployment-and-maintenance/upgrade/mysql-upgrade-from-8.0.4-to-8.4.x-rhel-internet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
