How to Install MariaDB 10.6 on AlmaLinux 8

MariaDB is one of the most popular open-source databases next to its originator MySQL. The original creators of MySQL developed MariaDB in response to fears that MySQL would suddenly become a paid service due to Oracle acquiring it in 2010. With its history of doing similar tactics, the developers behind MariaDB have promised to keep it open source and free from such fears as what has happened to MySQL.

MariaDB has become just as popular as MySQL with developers, with features such as advanced clustering with Galera Cluster 4, faster cache/indexes, storage engines, and features/extensions that you won’t find in MySQL.

In the following tutorial, you will learn how to install MariaDB 10.6 on AlmaLinux 8.

Prerequisites

  • Recommended OS: AlmaLinux 8.
  • User account: A user account with sudo privilages or root access (su command).

Updating Operating System

Update your AlmaLinux operating system to make sure all existing packages are up to date:

sudo dnf upgrade --refresh -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@localhost ~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on AlmaLinux.

To use the root account, use the following command with the root password to log in.

su

Create & Install MariaDB 10.6 Repository

The default MariaDB bundled with the AlmaLinux AppStream repository provides MariaDB 10.3, which is now quite dated. To install a newer version, most will look at MariaDB 10.5 and the most recent stable release MariaDB 10.6. Either can be installed by adding the official MariaDB repository.

First, open up using any text editor and create a MariaDB repository file on your system as follows:

sudo nano /etc/yum.repos.d/mariadb.repo

Next, copy and paste the following lines into the file for the latest version of MariaDB 10.6:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.6/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1 

If you want the alternative more season MariaDB 10.5, then use the next instead of MariaDB 10.6:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1 

Save the file (CTRL+O) and then exit (CLTRL+X).

To finish installing the new repository, you need to update your system repositories for AlmaLinux to sync the newly added repository. Use the following command to update as follows:

sudo dnf update

Install MariaDB 10.6

Now that you have installed the repository and updated your system repositories to reflect the new changes, it is time to install MariaDB. To do this, use the following command to install:

sudo dnf install mariadb-server mariadb

Example output:

How to Install MariaDB 10.6 on AlmaLinux 8

Type “Y,” then press the “ENTER KEY” to proceed with the installation.

Note, during the installation, you will be prompted to import the GPG key for MariaDB 10.6.

Example:

How to Install MariaDB 10.6 on AlmaLinux 8

Type “Y,” then press the “ENTER KEY” to proceed with the installation.

By default, MariaDB will not be enabled on boot, and will it not be switched on, you will need to do both as follows:

To start MariaDB, type the following:

sudo systemctl start mariadb

To start MariaDB on boot by default, type the following:

sudo systemctl enable mariadb

Once complete, you should verify that your MariaDB service is working correctly with the following command:

sudo systemctl status mariadb

You should get (status ok) to know everything is working.

Example:

How to Install MariaDB 10.6 on AlmaLinux 8

Secure MariaDB 10.6 with Security Script

When installing MariaDB fresh, default settings are considered weak by most standards and cause concern for potentially allowing intrusion or exploiting hackers. A solution is to run the installation security script that comes with the MariaDB installation.

First, use the following command to launch the (mariadb_secure_installation):

sudo mariadb-secure-installation

Next, follow below:

  • Setting the password for root accounts.
  • Removing root accounts that are accessible from outside the local host.
  • Removing anonymous-user accounts.
  • Removing the test database, which by default can be accessed by anonymous users.

Note, you use (Y) to remove everything.

Example:

How to Install MariaDB 10.6 on AlmaLinux 8

Login to MariaDB 10.6 Instance

Now that you have completed the post-installation installation security script, login into your MariaDB database can be done using the following:

sudo mysql -u root -p

You will be prompted to enter the root password that you set in either the installation setup or post-installation security script. Once inside the MySQL service instance, you can execute the following command as a test to see it in operation.

Type the following SHOW DATABASE command:

SHOW DATABASES;

For those new to MySQL, all commands syntax must end with “;”.

Example:

How to Install MariaDB 10.6 on AlmaLinux 8

To exit the terminal, type the following exit command:

EXIT;

Uninstall MariaDB 10.6

If you no longer wish to use MariaDB and want to remove it in full, execute the following command:

sudo dnf autoremove  mariadb-server mariadb-client

Example output:

How to Install MariaDB 10.6 on AlmaLinux 8

Type “Y,” then press the “ENTER KEY” to proceed with the uninstall.

Note that this command will remove most of the unused dependencies in the MariaDB installation to help clean up your system.

Comments and Conclusion

In the tutorial, you have learned how to install the latest version of MariaDB on the latest stable release AlmaLinux 8. Overall, it would help if you upgraded from the old stable 10.5 as it’s pretty seasoned now compared to 10.6, and there are considerable advantages in performance with upgrading. If you do upgrade, make sure to always back up your database before doing so to avoid countless hours of pain and utter frustration.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!