Friday, August 1, 2025

Step by Step Guide To Setup MySQL 8.4 on OCI

 

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 configuring the MySQL server.

 Pre-requisites

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

1. Install the  ncurses-compat-libs package on 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


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

      

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

  

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

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

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

 A screenshot of a computer

AI-generated content may be incorrect. 


         7. Assign necessary permission on 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

    A computer screen shot of a program

AI-generated content may be incorrect.

 

          A screen shot of a computer

AI-generated content may be incorrect. 

 

        9. Create a symbolic link to mysql binary installation

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

      

      10. Create the MySQL database configuration file.

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

           A screen shot of a computer

AI-generated content may be incorrect.

 Below is the content of MySQL configuration fileA screen shot of a computer

AI-generated content may be incorrect.

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

    

          12. Start the MySQL Instance

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

          13. Verify that the mysqld  process is running

                        $ ps -ef|grep mysqld

 $ netstat -an | grep 6401

A black background with colorful text

AI-generated content may be incorrect.

 

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

A computer screen with many small colored lines

AI-generated content may be incorrect.

        15. Test connection to the newly installed mysql database.

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

A computer screen with text

AI-generated content may be incorrect.

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

mysql> SET PASSWORD=’xxxxxxx';

mysql> status;

A screen shot of a computer

AI-generated content may be incorrect.

 

 






Steps to Deploy a 4-Node MySQL 8.4 InnoDB Cluster

      Introduction MySQL InnoDB Cluster provides native, highly available, and fault-tolerant database services. It packages three compone...