Install MySQL 8 on Oracle Linux 9

|
Last Updated:
|
|

Follow through this tutorial to learn how to install MySQL 8 on Oracle Linux 9. Being a popular open-source relational database management system, MySQL is available and can be installed on Oracle Linux 9.

Installing MySQL 8 on Oracle Linux 9

MySQL 8 package is provided by Oracle Linux 9 AppStream repos. The default Oracle Linuix AppStream repositories however may not provide the latest release version of MySQL 8 packages.

dnf provides mysql-server
mysql-server-8.0.28-1.el9.x86_64 : The MySQL server and related files
Repo        : ol9_appstream
Matched from:
Provide    : mysql-server = 8.0.28-1.el9

As you can see from the output above, Oracle Linux AppStream repository provides MySQL 8.0.28 whereas the current MySQL 8 release, as of this writing, is MySQL 8.0.30.

In order to ensure that you install latest release version of MySQL 8 on Oracle Linux, you need to install MySQL Yum repository. Thus, navigate to MySQL Yum repository downloads page and grab the repository release package for your platform.

You can as well get the download link and install it directly as follows;

sudo dnf install https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm

Once the installation is done, you can verify the version of the available MySQL 8 package;

dnf provides mysql-server
MySQL 8.0 Community Server                                                                                                                  137 kB/s | 210 kB     00:01    
MySQL Connectors Community                                                                                                                  287  B/s | 257  B     00:00    
MySQL Tools Community                                                                                                                        51 kB/s |  57 kB     00:01    
mysql-community-server-8.0.30-1.el9.x86_64 : A very fast and reliable SQL database server
Repo        : mysql80-community
Matched from:
Provide    : mysql-server = 8.0.30-1.el9

mysql-server-8.0.28-1.el9.x86_64 : The MySQL server and related files
Repo        : ol9_appstream
Matched from:
Provide    : mysql-server = 8.0.28-1.el9

As a result, you can now install MySQL 8 by running the command below;

dnf install mysql-server
Dependencies resolved.
============================================================================================================================================================================
 Package                                              Architecture                 Version                                    Repository                               Size
============================================================================================================================================================================
Installing:
 mysql-community-server                               x86_64                       8.0.30-1.el9                               mysql80-community                        48 M
Installing dependencies:
 mysql-community-client                               x86_64                       8.0.30-1.el9                               mysql80-community                       3.7 M
 mysql-community-client-plugins                       x86_64                       8.0.30-1.el9                               mysql80-community                       1.4 M
 mysql-community-common                               x86_64                       8.0.30-1.el9                               mysql80-community                       534 k
 mysql-community-icu-data-files                       x86_64                       8.0.30-1.el9                               mysql80-community                       2.2 M
 mysql-community-libs                                 x86_64                       8.0.30-1.el9                               mysql80-community                       1.5 M
 perl-Carp                                            noarch                       1.50-460.el9                               ol9_appstream                            34 k
 perl-Class-Struct                                    noarch                       0.66-479.el9                               ol9_appstream                            32 k
 perl-Encode                                          x86_64                       4:3.08-462.el9                             ol9_appstream                           1.8 M
 perl-Errno                                           x86_64                       1.30-479.el9                               ol9_appstream                            24 k
 perl-Exporter                                        noarch                       5.74-461.el9                               ol9_appstream                            37 k
 perl-Fcntl                                           x86_64                       1.13-479.el9                               ol9_appstream                            30 k
 perl-File-Basename                                   noarch                       2.85-479.el9                               ol9_appstream                            27 k
 perl-File-Path                                       noarch                       2.18-4.el9                                 ol9_appstream                            36 k
 perl-File-Temp                                       noarch                       1:0.231.100-4.el9                          ol9_appstream                            67 k
 perl-File-stat                                       noarch                       1.09-479.el9                               ol9_appstream                            27 k
 perl-Getopt-Long                                     noarch                       1:2.52-4.el9                               ol9_appstream                            71 k
 perl-Getopt-Std                                      noarch                       1.12-479.el9                               ol9_appstream                            25 k
 perl-HTTP-Tiny                                       noarch                       0.076-460.el9                              ol9_appstream                            63 k
 perl-IO                                              x86_64                       1.43-479.el9                               ol9_appstream                           119 k
 perl-IPC-Open3                                       noarch                       1.21-479.el9                               ol9_appstream                            32 k
 perl-MIME-Base64                                     x86_64                       3.16-4.el9                                 ol9_appstream                            38 k
 perl-POSIX                                           x86_64                       1.94-479.el9                               ol9_appstream                           106 k
 perl-PathTools                                       x86_64                       3.78-461.el9                               ol9_appstream                           108 k
 perl-Pod-Escapes                                     noarch                       1:1.07-460.el9                             ol9_appstream                            21 k
 perl-Pod-Perldoc                                     noarch                       3.28.01-461.el9                            ol9_appstream                           116 k
 perl-Pod-Simple                                      noarch                       1:3.42-4.el9                               ol9_appstream                           272 k
 perl-Pod-Usage                                       noarch                       4:2.01-4.el9                               ol9_appstream                            48 k
 perl-Scalar-List-Utils                               x86_64                       4:1.56-461.el9                             ol9_appstream                            83 k
 perl-SelectSaver                                     noarch                       1.02-479.el9                               ol9_appstream                            21 k
 perl-Socket                                          x86_64                       4:2.031-4.el9                              ol9_appstream                            62 k
 perl-Storable                                        x86_64                       1:3.21-460.el9                             ol9_appstream                           100 k
 perl-Symbol                                          noarch                       1.08-479.el9                               ol9_appstream                            24 k
 perl-Term-ANSIColor                                  noarch                       5.01-461.el9                               ol9_appstream                            54 k
 perl-Term-Cap                                        noarch                       1.17-460.el9                               ol9_appstream                            27 k
 perl-Text-ParseWords                                 noarch                       3.30-460.el9                               ol9_appstream                            17 k
 perl-Text-Tabs+Wrap                                  noarch                       2013.0523-460.el9                          ol9_appstream                            29 k
 perl-Time-Local                                      noarch                       2:1.300-7.el9                              ol9_appstream                            41 k
 perl-constant                                        noarch                       1.33-461.el9                               ol9_appstream                            28 k
 perl-if                                              noarch                       0.60.800-479.el9                           ol9_appstream                            23 k
 perl-interpreter                                     x86_64                       4:5.32.1-479.el9                           ol9_appstream                            86 k
 perl-libs                                            x86_64                       4:5.32.1-479.el9                           ol9_appstream                           2.7 M
 perl-mro                                             x86_64                       1.23-479.el9                               ol9_appstream                            38 k
 perl-overload                                        noarch                       1.31-479.el9                               ol9_appstream                            55 k
 perl-overloading                                     noarch                       0.02-479.el9                               ol9_appstream                            22 k
 perl-parent                                          noarch                       1:0.238-460.el9                            ol9_appstream                            15 k
 perl-podlators                                       noarch                       1:4.14-460.el9                             ol9_appstream                           135 k
 perl-subs                                            noarch                       1.03-479.el9                               ol9_appstream                            21 k
 perl-vars                                            noarch                       1.05-479.el9                               ol9_appstream                            23 k

Transaction Summary
============================================================================================================================================================================
Install  49 Packages

Total download size: 64 M
Installed size: 352 M
Is this ok [y/N]: y

Running MySQL 8 on Oracle Linux 9

You can start and enable MySQL 8 server to run on system boot after the installation.

sudo systemctl enable --now mysqld

To check the status of MySQL 8 server;

systemctl status mysqld
● mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
     Active: active (running) since Tue 2022-09-06 08:59:55 EAT; 8s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 28142 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
   Main PID: 28219 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 5832)
     Memory: 424.4M
        CPU: 5.039s
     CGroup: /system.slice/mysqld.service
             └─28219 /usr/sbin/mysqld

Sep 06 08:59:43 localhost.localdomain systemd[1]: Starting MySQL Server...
Sep 06 08:59:55 localhost.localdomain systemd[1]: Started MySQL Server.

Oracle Linux MySQL 8 Initial Security

When the MySQL service is started for the first time;

  • The MySQL server is initialized.
  • SSL certificate and key files are generated in the data directory.
  • validate_password is installed and enabled.
  • A superuser account 'root'@'localhost is created.
  • A password for the superuser is set and stored in the error log file.

Before you can begin to use MySQL, it is recommended that you ran the initial secure installation script. The script is used to remove test MySQL server databases, remove anonymous users in the database, disable remote root login, set the password strength.

Before you can run the MySQL secure installation script, you need to obtain the root password that was set when the MySQL server was initialized.

sudo grep 'temporary password' /var/log/mysqld.log

Sample output;

2022-09-06T05:59:49.712475Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =moSFn9Djmdj

Once you have the password, run the script by simply executing the command;

mysql_secure_installation

Enter the password extracted above, when prompted.

Next, change the password and proceed to remove anonymous user, disallow remote root login, remove test databases and reload privilege tables.


Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password: 

Re-enter new password: 
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

You can now login to your MySQL 8 server as a root user with the password set above.

mysql -u root -p

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.30 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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>

To show MySQL version, you can run the query;

show variables like "version%";

+-------------------------+------------------------------+
| Variable_name           | Value                        |
+-------------------------+------------------------------+
| version                 | 8.0.30                       |
| version_comment         | MySQL Community Server - GPL |
| version_compile_machine | x86_64                       |
| version_compile_os      | Linux                        |
| version_compile_zlib    | 1.2.12                       |
+-------------------------+------------------------------+
5 rows in set (0.01 sec)

You can as well run the command below on command line to show database version.

mysql -V
mysql  Ver 8.0.30 for Linux on x86_64 (MySQL Community Server - GPL)

That is all on how to install MySQL 8 on Oracle Linux 9.

Other Tutorials

Configure Guacamole MySQL Database Authentication

Enable MSSQL Server and Database Level Auditing

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment