# MySQL 8.4.x on Ubuntu 22.04+

## Introduction

This document provides a step-by-step guide to installing **MySQL version 8.4.x** on Ubuntu 22.04. It outlines the prerequisites, installation procedure, initial configuration, and tuning parameters recommended by OvalEdge to optimize database performance and compatibility.\
This guide is intended for **system administrators, DevOps engineers, and database administrators** deploying MySQL in enterprise environments.

### Prerequisites

Before beginning the installation, ensure the following system and environment requirements are met:

1. **Operating System**: Ubuntu 22.04 LTS or later
2. **Privileges**: A user account with `sudo` privileges
3. **Network**: Stable internet connectivity on the target VM
4. **Resources**: Minimum 4 GB RAM (8 GB+ recommended for production)
5. **Repository Access**: Outbound access to `https://dev.mysql.com`

### Installation Steps

1. **Update System Packages**
   * Refresh the system package index to ensure the latest repository metadata is available:

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

     \
     *Sample Reference Screenshot*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2Fwy8dvR92JnH1K57gfbAe%2F0.jpg?alt=media&#x26;token=d298d25f-5715-4902-ab54-c118922d4994" alt=""><figcaption></figcaption></figure>

2. **Download MySQL .deb Package**
   * Download the MySQL APT configuration package from the official MySQL website:

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

     \
     *Sample Reference Screenshot*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FadsriQULHLTAfr0d2jKa%2F1.jpg?alt=media&#x26;token=cd514b40-e10d-4568-a03d-477810fddd3d" alt=""><figcaption></figcaption></figure>

3. **Configure MySQL APT Repository**
   * Install the downloaded package. During installation, select **MySQL 8.4** when prompted:

     ```bash
     sudo dpkg -i mysql-apt-config_0.8.34-1_all.deb
     ```
   * Use arrow keys and *Enter* to navigate and confirm selections in the package configuration UI.

     \
     *Sample Reference Screenshot 01*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FxoNkaGOzNxspgWaW68qQ%2F2.jpg?alt=media&#x26;token=fecf080a-2b7f-4dda-b254-e58241c5d0ea" alt=""><figcaption></figcaption></figure>

     \
     \&#xNAN;*Sample Reference Screenshot 02*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FBB5DFPvtj8DfviD4DTge%2Fimage.png?alt=media&#x26;token=53b1741e-c01f-4358-b778-c8d783d06fa9" alt=""><figcaption></figcaption></figure>

     <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Select MySQL and click OK as shown in the screenshots above.</p></div>

4. **Update Repository Information**
   * Refresh the package list to include the MySQL APT repository:

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

     \
     *Sample Reference Screenshot*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2Ftd9LWQyYZcOkFJL8QLlI%2F4.jpg?alt=media&#x26;token=74f45c46-83bd-4c14-84ad-ccbf471aaccd" alt=""><figcaption></figcaption></figure>

5. **Install MySQL Server**
   * Install the MySQL server package:

     ```bash
     sudo apt-get install mysql-server -y
     ```
   * During installation, the system will prompt for the **root password**. Set and confirm the password as per organizational policy.<br>

     *Sample Reference Screenshot 01*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FowiPIKsmsUepQcSPJqJ5%2F5.jpg?alt=media&#x26;token=65692833-2954-4fa8-a23b-24e69cfb002c" alt=""><figcaption></figcaption></figure>

     \
     \&#xNAN;*Sample Reference Screenshot 02*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2Frjtpg4YZ8aWrtuW1MvdX%2Fimage.png?alt=media&#x26;token=82155ace-99ba-45be-a12f-3b760c0383c7" alt=""><figcaption></figcaption></figure>

     \
     \&#xNAN;*Sample Reference Screenshot 03*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FL3a1cpWr7Uzz8BiS1PwO%2Fimage.png?alt=media&#x26;token=7e0c4b9c-1e03-40b9-abd6-43d97e20cb34" alt=""><figcaption></figcaption></figure>

6. **Verify Installation**
   * Check the MySQL version:

     ```bash
     mysql --version
     ```
   * Connect to the MySQL shell:

     ```bash
     mysql -u root -p
     ```
   * Exit the MySQL shell:

     ```sql
     exit;
     ```

     \
     *Sample Reference Screenshot*

     <div align="left"><figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FnTUZ2mzMBzRyw8Oi71cT%2F8.jpg?alt=media&#x26;token=53f10793-1ec6-4e9e-a1b8-e5f6da1f059c" alt=""><figcaption></figcaption></figure></div>

7. **Update MySQL Configuration Parameters**
   * Open the MySQL server configuration file:

     ```bash
     sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
     ```
   * Add or update the following parameters under the `[mysqld]` section:

     ```ini
     max_binlog_size              = 1G
     binlog_expire_logs_seconds   = 2592000
     group_concat_max_len         = 4294967295
     max_connections              = 600
     max_allowed_packet           = 1G
     bind-address                 = 0.0.0.0
     innodb_buffer_pool_size      = 8G
     ```

     <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Set <code>bind-address=0.0.0.0</code> <strong>only if</strong> the MySQL server must accept remote connections (e.g., from an external application server).</p></div>

     <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Adjust <code>innodb_buffer_pool_size</code> based on available memory. The recommended value is <strong>50–70% of the total RAM</strong>.</p></div>

     \
     *Sample Reference Screenshot*

     <div align="left"><figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FpZaQ01Uy07WOsDDn4yu5%2F9.jpg?alt=media&#x26;token=59d76e50-4d0c-41d4-9798-9974344560d3" alt=""><figcaption></figcaption></figure></div>

8. **Restart and Enable MySQL Service**
   * Apply the new configuration by restarting the MySQL service:

     ```bash
     sudo systemctl restart mysql
     sudo systemctl enable mysql
     ```

     \
     *Sample Reference Screenshot*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FSFqVYpvlXzO1UddmcFgd%2F10.jpg?alt=media&#x26;token=5068959e-1ad7-4746-ac75-0330bb400f40" alt=""><figcaption></figcaption></figure>

### OvalEdge Database Initialization

9. **Download MasterScripts**
   * Transfer the **MasterScripts SQL file** provided by OvalEdge to the MySQL VM. Use `scp`, `wget`, or other secure transfer methods.

     Example (using wget):

     ```bash
     wget <Master_scripts_URL>
     ```

     \
     *Sample Reference Screenshot*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FOg2DeHfJuKKKFVdDTM4z%2F11.jpg?alt=media&#x26;token=ca0425e9-13be-44e5-8313-6c3d0aee26e8" alt=""><figcaption></figcaption></figure>

10. **Execute MasterScripts**
    * Log in to MySQL:

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

      \
      \&#xNAN;*Sample Reference Screenshot*

      <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FnluGwneoz4tr0PtBlIxt%2F12.jpg?alt=media&#x26;token=1064ba31-fe6d-4a15-9b47-a4f90e433b54" alt=""><figcaption></figcaption></figure>
    * Within the MySQL prompt, run:

      ```sql
      source <Path of MasterScripts file>
      ```
    * Exit the MySQL shell:

      ```sql
      exit;
      ```

11. **Verify Database Creation**

* Reconnect to MySQL:

  ```bash
  mysql -u root -p
  ```
* Check that the required databases are created:

  ```sql
  SHOW DATABASES;
  ```

  \
  *Sample Reference Screenshot*

  <div align="left"><figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FCCxirnYyPdBDWwhCMThw%2F13.jpg?alt=media&#x26;token=f8d01165-472f-497a-ab7c-935860e5df73" alt=""><figcaption></figcaption></figure></div>

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>The presence of the <code>ovaledgedb</code> confirms successful database initialization.</p></div>
