How to Install MySQL 8 on Oracle Linux 8

In this post I am going to share how to install the MySQL 8 Community Edition on Oracle Linux 8.

Before you download the RPM, confirm which version of Linux you are using, by checking /etc/redhat-release or /etc/oracle-release, for example.

# cat /etc/redhat-release; cat /etc/oracle-release
Red Hat Enterprise Linux release 8.8 (Ootpa)
Oracle Linux Server release 8.8

I have confirmed I am running Oracle Linux 8 and can therefore proceed to the MySQL Community Download site.

Adding the MySQL Yum Repository

The MySQL Yum repository is the place to go for Oracle Linux / Red Hat Enterprise Linux (6,7,8,9) and Fedora (37,38) MySQL community edition server RPMs.

MySQL Community Downloads

Select the required RPM package and download using wget.

# wget https://repo.mysql.com//mysql80-community-release-el8-5.noarch.rpm
--2023-07-06 14:31:29--  https://repo.mysql.com//mysql80-community-release-el8-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.103.177.89
Connecting to repo.mysql.com (repo.mysql.com)|104.103.177.89|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14948 (15K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el8-5.noarch.rpm’

mysql80-community-release-el8-5.noarch.rpm 100%[============================================================>]  14.60K  --.-KB/s in 0s

2023-07-06 14:31:30 (175 MB/s) - ‘mysql80-community-release-el8-5.noarch.rpm’ saved [14948/14948]

Install the downloaded RPM package.

# yum -y install mysql80-community-release-el8-5.noarch.rpm
Last metadata expiration check: 0:03:02 ago on Thu 06 Jul 2023 02:31:40 PM BST.
Dependencies resolved.
=========================================================================================
 Package                                               Architecture                       Version                           Repository                                Size
=========================================================================================
Installing:
 mysql80-community-release                             noarch                             el8-5                             @commandline                              15 k

Transaction Summary
=========================================================================================
Install  1 Package

Total size: 15 k
Installed size: 8.6 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                   1/1
  Installing       : mysql80-community-release-el8-5.noarch                                                                                                            1/1
  Running scriptlet: mysql80-community-release-el8-5.noarch                                                                                                            1/1
   Warning: native mysql package from platform vendor seems to be enabled.
    Please consider to disable this before installing packages from repo.mysql.com.
    Run: yum module -y disable mysql

  Verifying        : mysql80-community-release-el8-5.noarch                                                                                                            1/1

Installed:
  mysql80-community-release-el8-5.noarch

Complete!

The installation command adds the MySQL Yum repository to your system’s repository list and downloads the GnuPG key to check the integrity of the software packages.

# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community MySQL Connectors Community
mysql-tools-community      MySQL Tools Community
mysql80-community          MySQL 8.0 Community Server

Disable MySQL

Oracle Linux 8 includes a MySQL module that is enabled by default, unless this module is disabled, it masks packages provided by MySQL repositories.

To disable the included module and make the MySQL repository packages visible, use the following command yum module disable mysql.

# yum module disable mysql
Last metadata expiration check: 4:00:33 ago on Mon 10 Jul 2023 09:39:01 AM BST.
Dependencies resolved.
=========================================================================================
 Package                       Architecture                 Version                        Repository                     Size
=========================================================================================
Disabling modules:
 mysql

Transaction Summary
=========================================================================================

Is this ok [y/N]: y
Complete!

MySQL Install

We can now use yum install mysql-community-server to install MySQL 8 Community Server.

# yum install mysql-community-server
Last metadata expiration check: 4:04:05 ago on Mon 10 Jul 2023 09:39:01 AM BST.
Dependencies resolved.
=====================================================================================
 Package                                         Architecture            Version                        Repository                          Size
=====================================================================================
Installing:
 mysql-community-server                          x86_64                  8.0.33-1.el8                   mysql80-community                   64 M
     replacing  mariadb-connector-c-config.noarch 3.1.11-2.el8_3
Installing dependencies:
 mysql-community-client                          x86_64                  8.0.33-1.el8                   mysql80-community                   16 M
 mysql-community-client-plugins                  x86_64                  8.0.33-1.el8                   mysql80-community                  3.5 M
 mysql-community-common                          x86_64                  8.0.33-1.el8                   mysql80-community                  667 k
 mysql-community-icu-data-files                  x86_64                  8.0.33-1.el8                   mysql80-community                  2.1 M
 mysql-community-libs                            x86_64                  8.0.33-1.el8                   mysql80-community                  1.5 M

Transaction Summary
=====================================================================================
Install  6 Packages

Total download size: 89 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): mysql-community-common-8.0.33-1.el8.x86_64.rpm                                                            509 kB/s | 667 kB     00:01
(2/6): mysql-community-client-plugins-8.0.33-1.el8.x86_64.rpm                                                    2.1 MB/s | 3.5 MB     00:01
(3/6): mysql-community-icu-data-files-8.0.33-1.el8.x86_64.rpm                                                    4.5 MB/s | 2.1 MB     00:00
(4/6): mysql-community-libs-8.0.33-1.el8.x86_64.rpm                                                              7.6 MB/s | 1.5 MB     00:00
(5/6): mysql-community-client-8.0.33-1.el8.x86_64.rpm                                                            5.2 MB/s |  16 MB     00:03
(6/6): mysql-community-server-8.0.33-1.el8.x86_64.rpm                                                             17 MB/s |  64 MB     00:03
--------------------------------------------------------------------------------------
Total                                                                                                             16 MB/s |  89 MB     00:05
MySQL 8.0 Community Server                                                                                       3.0 MB/s | 3.1 kB     00:00
Importing GPG key 0x3A79BD29:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: 859B E8D7 C586 F538 430B 19C2 467B 942D 3A79 BD29
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Is this ok [y/N]: y
Key imported successfully
MySQL 8.0 Community Server                                                                                       1.9 MB/s | 1.9 kB     00:00
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: A4A9 4068 76FC BD3C 4567 70C8 8C71 8D3B 5072 E1F5
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                         1/1
  Installing       : mysql-community-common-8.0.33-1.el8.x86_64                                                                              1/7
  Installing       : mysql-community-client-plugins-8.0.33-1.el8.x86_64                                                                      2/7
  Installing       : mysql-community-libs-8.0.33-1.el8.x86_64                                                                                3/7
  Running scriptlet: mysql-community-libs-8.0.33-1.el8.x86_64                                                                                3/7
  Installing       : mysql-community-client-8.0.33-1.el8.x86_64                                                                              4/7
  Installing       : mysql-community-icu-data-files-8.0.33-1.el8.x86_64                                                                      5/7
  Running scriptlet: mysql-community-server-8.0.33-1.el8.x86_64                                                                              6/7
  Installing       : mysql-community-server-8.0.33-1.el8.x86_64                                                                              6/7
warning: /etc/my.cnf created as /etc/my.cnf.rpmnew

  Running scriptlet: mysql-community-server-8.0.33-1.el8.x86_64                                                                              6/7
  Obsoleting       : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                                        7/7
  Running scriptlet: mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                                        7/7
  Verifying        : mysql-community-client-8.0.33-1.el8.x86_64                                                                              1/7
  Verifying        : mysql-community-client-plugins-8.0.33-1.el8.x86_64                                                                      2/7
  Verifying        : mysql-community-common-8.0.33-1.el8.x86_64                                                                              3/7
  Verifying        : mysql-community-icu-data-files-8.0.33-1.el8.x86_64                                                                      4/7
  Verifying        : mysql-community-libs-8.0.33-1.el8.x86_64                                                                                5/7
  Verifying        : mysql-community-server-8.0.33-1.el8.x86_64                                                                              6/7
  Verifying        : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                                        7/7

Installed:
  mysql-community-client-8.0.33-1.el8.x86_64                          mysql-community-client-plugins-8.0.33-1.el8.x86_64
  mysql-community-common-8.0.33-1.el8.x86_64                          mysql-community-icu-data-files-8.0.33-1.el8.x86_64
  mysql-community-libs-8.0.33-1.el8.x86_64                            mysql-community-server-8.0.33-1.el8.x86_64

Complete!

Create MySQL Linux group, user and update directory ownership and permissions as required, for example.

# groupadd -g 27 -o -r mysql
# useradd -r -g mysql -s /bin/false mysql
# id mysql
uid=973(mysql) gid=27(mysql) groups=27(mysql)

# mount | grep mysql
/dev/mapper/mysql_base on /mysql/base type ext4 (rw,relatime,seclabel,stripe=1024)
/dev/mapper/mysql_undo on /mysql/undo type ext4 (rw,relatime,seclabel,stripe=1024)
/dev/mapper/mysql_log on /mysql/log type ext4 (rw,relatime,seclabel,stripe=1024)
/dev/mapper/mysql_binlog on /mysql/binlog type ext4 (rw,relatime,seclabel,stripe=1024)

# chown -R mysql:mysql /mysql
# chmod -R 755 /mysql

# mkdir -p /var/log/mysql
# chown mysql:mysql /var/log/mysql

Configure MySQL

Edit the /etc/my.cnf file and updated any required MySQL database parameters, I have included mine as an example.

[client-server]
port=3306
socket=/var/lib/mysql/mysql.sock

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

[mysqld]
general_log_file=/var/log/mysql/mysql.log
general_log=1

basedir=/mysql/base
datadir=/mysql/base/data
log-bin=/mysql/binlog/binlog
tmpdir =/tmp

# === InnoDB Settings ===
default_storage_engine=InnoDB
innodb_data_home_dir=/mysql/base/data
innodb_data_file_path=ibdata1:12M:autoextend
innodb_log_group_home_dir=/mysql/log
innodb_undo_directory=/mysql/undo
innodb_tmpdir=/tmp
innodb_temp_data_file_path=ibtmp1:50M;ibtmp2:12M:autoextend:max:5G

Starting the MySQL Server

Start the MySQL server with the following command:

# systemctl start mysqld

You can check the status of the MySQL server with the following command:

# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-07-10 13:55:40 BST; 1min 2s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 2975956 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 2976145 (mysqld)
   Status: "Server is operational"
    Tasks: 37 (limit: 3297099)
   Memory: 451.2M
   CGroup: /system.slice/mysqld.service
           └─2976145 /usr/sbin/mysqld

Jul 10 13:55:39 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:39.547999Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has start>
Jul 10 13:55:39 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:39.723763Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
Jul 10 13:55:40 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:40.057656Z 0 [Warning] [MY-013829] [Server] Missing data directory for ICU>
Jul 10 13:55:40 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:40.060817Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self >
Jul 10 13:55:40 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:40.060886Z 0 [System] [MY-013602] [Server] Channel mysql_main configured t>
Jul 10 13:55:40 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:40.068849Z 0 [ERROR] [MY-013129] [Server] A message intended for a client >
Jul 10 13:55:40 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:40.068898Z 0 [ERROR] [MY-013129] [Server] A message intended for a client >
Jul 10 13:55:40 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:40.091494Z 0 [System] [MY-011323] [Server] X Plugin ready for connections.>
Jul 10 13:55:40 z-rac1.uklab.purestorage.com mysqld[2976145]: 2023-07-10T12:55:40.091603Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for con>
Jul 10 13:55:40 z-rac1.uklab.purestorage.com systemd[1]: Started MySQL Server.
#

The mysqld service is enabled by default, and it starts at system reboot, but if disabled can be enabled manually to autostart on reboot with:

# systemctl enable mysqld

To confirm MySQL version and edition, use mysql –version.

# mysql --version
mysql  Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)

Alternatively if we logon using mysql -u root -p, we can see a MySQL Community Server version of 8.0.33.

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

Finally, as I plan to use the MySQL Shell in a future blog post let’s also install that using yum install mysql-shell.

# yum install mysql-shell
Last metadata expiration check: 1:47:47 ago on Mon 10 Jul 2023 01:45:18 PM BST.
Dependencies resolved.
============================================================================================================
 Package                               Architecture       Version                                            Repository                         Size
============================================================================================================
Installing:
 mysql-shell                           x86_64             8.0.33-1.el8                                       mysql-tools-community              27 M
Installing dependencies:
 python39-libs                         x86_64             3.9.16-1.module+el8.8.0+21002+9d0e08bf             ol8_appstream                     8.2 M
 python39-pip-wheel                    noarch             20.2.4-7.module+el8.6.0+20625+ee813db2             ol8_appstream                     1.1 M
 python39-setuptools-wheel             noarch             50.3.2-4.module+el8.5.0+20364+c7fe1181             ol8_appstream                     497 k
Installing weak dependencies:
 python39                              x86_64             3.9.16-1.module+el8.8.0+21002+9d0e08bf             ol8_appstream                      33 k
 python39-pip                          noarch             20.2.4-7.module+el8.6.0+20625+ee813db2             ol8_appstream                     1.9 M
 python39-setuptools                   noarch             50.3.2-4.module+el8.5.0+20364+c7fe1181             ol8_appstream                     871 k
Enabling module streams:
 python39                                                 3.9

Transaction Summary
============================================================================================================
Install  7 Packages

Total download size: 39 M
Installed size: 229 M
Is this ok [y/N]: y
Downloading Packages:
(1/7): python39-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64.rpm                                                     37 kB/s |  33 kB     00:00
(2/7): python39-pip-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch.rpm                                                2.6 MB/s | 1.9 MB     00:00
(3/7): python39-pip-wheel-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch.rpm                                          3.5 MB/s | 1.1 MB     00:00
(4/7): python39-libs-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64.rpm                                               3.9 MB/s | 8.2 MB     00:02
(5/7): python39-setuptools-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch.rpm                                         5.3 MB/s | 871 kB     00:00
(6/7): python39-setuptools-wheel-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch.rpm                                   2.7 MB/s | 497 kB     00:00
(7/7): mysql-shell-8.0.33-1.el8.x86_64.rpm                                                                           8.5 MB/s |  27 MB     00:03
------------------------------------------------------------------------------------------------------------
Total                                                                                                                 12 MB/s |  39 MB     00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                       1/1
  Installing       : python39-setuptools-wheel-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch                                                                 1/7
  Installing       : python39-pip-wheel-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch                                                                        2/7
  Installing       : python39-libs-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64                                                                             3/7
  Installing       : python39-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64                                                                                  4/7
  Running scriptlet: python39-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64                                                                                  4/7
  Installing       : python39-setuptools-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch                                                                       5/7
  Running scriptlet: python39-setuptools-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch                                                                       5/7
  Installing       : python39-pip-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch                                                                              6/7
  Running scriptlet: python39-pip-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch                                                                              6/7
  Installing       : mysql-shell-8.0.33-1.el8.x86_64                                                                                                         7/7
  Running scriptlet: mysql-shell-8.0.33-1.el8.x86_64                                                                                                         7/7
  Verifying        : mysql-shell-8.0.33-1.el8.x86_64                                                                                                         1/7
  Verifying        : python39-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64                                                                                  2/7
  Verifying        : python39-libs-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64                                                                             3/7
  Verifying        : python39-pip-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch                                                                              4/7
  Verifying        : python39-pip-wheel-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch                                                                        5/7
  Verifying        : python39-setuptools-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch                                                                       6/7
  Verifying        : python39-setuptools-wheel-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch                                                                 7/7

Installed:
  mysql-shell-8.0.33-1.el8.x86_64                                                    python39-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64
  python39-libs-3.9.16-1.module+el8.8.0+21002+9d0e08bf.x86_64                        python39-pip-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch
  python39-pip-wheel-20.2.4-7.module+el8.6.0+20625+ee813db2.noarch                   python39-setuptools-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch
  python39-setuptools-wheel-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch

Complete!

Summary

In this post I have shared how to install MySQL 8.0 Community Edition and the MySQL on Oracle Linux 8.

In my next post I will look at using the MySQL Shell with s3 Object Storage.

Leave a Reply

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: