# MySQL Upgrade from 8.0.4 to 8.4.x  (Ubuntu)

This article provides step-by-step instructions to upgrade MySQL from **version 8.0.4 to 8.4**.**x.** It covers prerequisites, pre-upgrade checks, installation steps, post-upgrade validations, and rollback procedures to ensure a safe and production-ready upgrade.

### Prerequisites

* **OS Compatibility**
  * Confirm the operating system supports MySQL 8.4.
  * **Recommended:** Ubuntu 22.04 LTS or later.
  * Check OS version:

    ```bash
    cat /etc/os-release
    ```
* **System Requirements**
  * **Disk space:** Sufficient for backups and rollback
  * **Memory:** Minimum 16 GB RAM
  * **Access:** Root or sudo privileges

### Pre-Upgrade Checks

* **Backup**
  * **Logical backup:**

    ```bash
    mysqldump -u root -p ovaledgedb > /home/ubuntu/mysql_backup/ovaledgedb_backup.sql
    ```

    Ensure you use the correct schema.

    <figure><img src="/files/B8szMZNt3RiBWJAR6Dtk" alt=""><figcaption></figcaption></figure>
  * Physical backup (recommended):
    * Use Percona XtraBackup or filesystem-level copy.
  * **Backup configuration files:**

    ```bash
    sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /home/ubuntu/mysql_backup/
    sudo cp -a /var/lib/mysql /home/ubuntu/mysql_backup/
    ```

    <figure><img src="/files/IqXMe52nXaAmSA0TcLxD" alt=""><figcaption></figcaption></figure>
* **Collect Pre-Upgrade Database Information**
  * **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/2Qd78zcUn8OisUXaDtMj" alt=""><figcaption></figcaption></figure>
  * Row count query:\
    \[[Download Query File](https://ovaledge.s3.us-west-1.amazonaws.com/queries/dbsize.sql?utm_source=chatgpt.com)]

    <figure><img src="/files/eKyFG6juUMHd0b4XafwB" alt=""><figcaption></figcaption></figure>
  * Save query outputs for post-upgrade validation.

### Upgrade Execution

* **Stop MySQL Service**

  ```bash
  sudo systemctl stop mysql
  ```

  <figure><img src="/files/wkn0yY4Y0WfMF4nLK4tR" alt=""><figcaption></figcaption></figure>
* **Download MySQL APT Repository**&#x20;
* Update package manager repo i,e, using deb packages for ubuntu.

  ```bash
  cd
  wget https://dev.mysql.com/get/mysql-apt-config_0.8.33-1_all.deb
  ```

  <figure><img src="/files/WG64GNi4hPH1vrA3CgBO" alt=""><figcaption></figcaption></figure>
* **Update Repository**\
  Update the deb packages as shown below.

  ```bash
  sudo dpkg -i mysql-apt-config_0.8.33-1_all.deb
  ```

  * Select the highlighted package below and hit Enter.

    <figure><img src="/files/owlrYgIPQscuvZKOJKcu" alt=""><figcaption></figcaption></figure>
  * Select MySQL 8.4 LTS when prompted.

    <figure><img src="/files/B49YOtQAchvlpgEFp984" alt=""><figcaption></figcaption></figure>
  * Confirm selections and continue.

    <figure><img src="/files/f9vGBUl1lsgrOSpRQJoj" alt=""><figcaption></figcaption></figure>
  * Finally you will get below screen,

    <figure><img src="/files/TpJZFUm3ezM6Xmu5j8gm" alt=""><figcaption></figcaption></figure>
* **Update Packages**\
  Update the apt package repository.

  ```bash
  sudo apt update -y
  ```

  <figure><img src="/files/upnBp0wifQWAEEQI7MZK" alt=""><figcaption></figcaption></figure>
* **Upgrade MySQL Server**\
  Run the following command to upgrade the MySQL server:

  ```bash
  sudo apt-get install mysql-server
  ```

  <figure><img src="/files/GttNqhCsUjbm3Q2jijrv" alt=""><figcaption></figcaption></figure>
* **Update Configuration**\
  Open the MySQL configuration file:

  ```bash
  sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
  ```

  Add:

  ```
  mysql_native_password=ON
  ```

  <figure><img src="/files/KVgZDB2V7OEyzprUbhOm" alt=""><figcaption></figcaption></figure>

  Save file and restart MySQL

  ```bash
  sudo systemctl restart mysql
  ```

  <figure><img src="/files/d1g3nfz7uAXx2FtePjxy" alt=""><figcaption></figcaption></figure>
* **Verify Version**

  ```bash
  mysql --version
  ```

  <figure><img src="/files/siphjzr2d5Pq0dF5UHkP" alt=""><figcaption></figcaption></figure>

### Post-Upgrade Validations

* **Row Count Verification**

  ```bash
  mysql -u root -p
  ```

  Run \[[Row Count Query](https://ovaledge.s3.us-west-1.amazonaws.com/queries/dbsize.sql?utm_source=chatgpt.com)] and compare results with pre-upgrade counts.

  <figure><img src="/files/2RB4YE1fUHzo8L4B84A0" alt=""><figcaption></figcaption></figure>
* **Database Size Verification**<br>

  ```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/D1ZrQZs4QsoIE7yiISxs" alt=""><figcaption></figcaption></figure>

  Compare with pre-upgrade values.
* **Update MySQL Parameters**\
  Edit `/etc/mysql/mysql.conf.d/mysqld.cnf` and add:

  ```
  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
  ```

  <figure><img src="/files/JkI2mW2GgwQ1d54cOM2X" alt=""><figcaption></figcaption></figure>

  Adjust values based on instance size.\
  **Restart MySQL:**

  ```bash
  sudo systemctl restart mysql
  ```

  <figure><img src="/files/RYtQ6uTMvOzQdgQ0ycFE" alt=""><figcaption></figcaption></figure>
* **Update OvalEdge User Password**

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

  ```bash
  tail -n 100 /var/log/mysql/error.log
  ```

  <figure><img src="/files/90V2lPA0uNiGJnoM1bLG" alt=""><figcaption></figcaption></figure>
* Once validations are complete, point the OvalEdge application to MySQL 8.4.

### Rollback Plan (If Needed)

* Back up MySQL configuration and data directory:

  ```bash
  sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /home/ubuntu/mysql8.4_backup/
  sudo cp -a /var/lib/mysql /home/ubuntu/mysql8.4_backup/
  ```

  <figure><img src="/files/j288ps6nxLMb9vbU6BXI" alt=""><figcaption></figcaption></figure>
* Stop MySQL service.
* Reinstall MySQL 8.0.4.
* Restore data from backups.

### Additional Information

* Test MySQL 8.4 installation in a separate folder before applying in production.
* Example: MySQL 8.4.4 installation in a separate folder on Ubuntu.

***

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-ubuntu.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.
