Skip to content

Step by Step Guide To Setup MySQL 8.4 on OCI

Edson Edewor Aug 4, 2025 9:42:50 AM
Step by Step Guide To Setup MySQL 8.4 on OCI
4:03

Introduction

As organizations increasingly turn to the cloud for scalable, secure, and cost-effective infrastructure, Oracle Cloud Infrastructure (OCI) has emerged as a powerful platform for running high-performance workloads. For developers and DBAs looking to maintain full control over their database environment, deploying MySQL 8.4 on an OCI Compute instance offers the perfect blend of flexibility, performance, and cloud-native capabilities.

In this blog post, I will walk you through the process of setting up MySQL 8.4 on a virtual machine in OCI, covering installation and configuration of the MySQL server.

 Pre-requisites

  •            Provision OCI compute instance Linux 8.0 x86_64 bits.
  •             Access to the Oracle support portal to download MySQL 8.4.0.
  •             Prepare private and public SSH keys for the OCI virtual machine

1. Install the the ncurses-compat-libs package on an Oracle Linux 8 Virtual Machine. This package is required when installing MySQL Enterprise Edition using the tar package. This requirement does not apply when using RPM packages for installation.

$ sudo yum install -y ncurses-compat-libs

 

  1. Add the below environment variables to the opc user.

export PATH=$PATH:/mysql/mysql-latest/bin

export MYSQL_PS1="\\u on \\h>\\_"

 $ vi /home/opc/.bashrc

 

       3 Create a new user/group for the MySQL service and add mysql group to opc. Note that login to mysql user is disabled for security reasons. 

$ sudo groupadd mysql

$ sudo useradd -r -g mysql -s /bin/false mysql

 

        4 . Create new directory structure:

           $ sudo mkdir /mysql/ /mysql/etc/6401 /mysql/data/6401 /mysql/log /mysql/temp /mysql/binlog

          $ cd /mysql/binlog 

          $ mkdir -p replicate/64001 relay/6401

          $ sudo chown -R mysql:mysql /MySQL

          $ sudo chmod -R 750 /mysql

          $ sudo chown -R mysql:mysql /mysql 

      

  1.      Validate the operating system to confirm that it is x86_64 bits.

  

  1. Download the MySQL tar binary from the Oracle support portal and upload it to an OCI storage bucket. 

         Use the wget command to download the tar binary on the virtual machine.

        $ sudo wget https://MySQLp36562194_840_Linux-x86-64.zip

  

 

  1. Assign the necessary permissions to the newly downloaded binary. 

             

             $ sudo chown MySql :mysql MySQLp36562194_840_Linux-x86-64.zip

 

  8. Unzip the binary file using the command below. 

         $ sudo unzip MySQLp36562194_840_Linux-x86-64.zip

         $ sudo tar -xvf mysql-commercial-8.4.0-linux-glibc2.28-x86_64.tar.xz

 

    

 

           

 

  1. Create a symbolic link to mysql binary installation

             $ sudo ln -s  mysql-commercial-8.4.0-linux-glibc2.28-x86_64 mysql8.4.0 

      

  1.    Create the MySQL database configuration file.

               $ sudo vi /mysql/etc/my.6401.cnf      

           

 Below is the content of the MySQL configuration file

  1. Initialize and start the MySQL instance

              $ sudo /mysql/mysql8.4.0/bin/mysqld --defaults-file=/mysql/etc/my.6401.cnf  \

               --initialize --user=mysql  --basedir=/mysql/mysql8.4.0  --datadir=/mysql/data/6401

    

  1. Start the MySQL Instance

                 $ sudo /mysql/mysql8.4.0/bin/mysqld --defaults-file=/mysql/etc/my.6401.cnf --user=mysql &

  1. Verify that the mysqld  process is running

                        $ ps -ef|grep mysqld

 $ netstat -an | grep 6401

 

  1. Retrieve root password for first login. The temporary password for root is located inside the logfile.

                $ cat /mysql/log/mysqld.6401.log or grep -i 'temporary password' /mysql/log/mysqld.6401.log

  1.        Test connection to the newly installed MySQL database.

              $ sudo /mysql/mysql8.4.0/bin/mysql -uroot -p -h 127.0.0.1 -P6401

  1. Change the root password using the command below and check the status of the database.

mysql> SET PASSWORD=’xxxxxxx';

mysql> status;

Leave a Comment