The growth and usage of the MariaDB server for the past 6 years is an admirable milestone. It has similar footprints with the MySQL database because of one primary reason; MySQL generated the fork responsible for its development. However, MariaDB is a community-developed project with richer and more dynamic features when compared to the MySQL database.
RHEL/CentOS Linux operating system distributions are becoming prone to the use of MySQL as their default or preferred database software. The interests of these operating systems distributions towards MariaDB started when Oracle proclaimed its interest in acquiring MySQL. This article is dedicated to RHEL/CentOS users that are yet to switch to MariaDB.
The release of Red Hat Enterprise Linux 7 (RHEL 7) dates back to 2014. To date, we can associate it with 7 point releases. Upstream RHEL source code release is shadowed by the CentOS project. RHEL’s community binary builds came into the picture several months later. Also, CentOS 7 release dates back to 2014. Its specific release date is July 2014. Both RHEL 7 and CentOS 7 are adaptable hosts or OS environments for the MariaDB server.
The RHEL 7.x release series is coming to a halt after Red Hat’s ambition to make RHEL 7.7 its last point release. With the end-of-support date for this series (RHEL 7.7) scheduled to be August 2021, the only viable option for RHEL users would be to consider upgrading to RHEL 8.
There are several benefits to reap from switching to RHEL 8 in comparison to its predecessor RHEL 7. First, there is the issue of impeccable OS environment enhancements. RHEL 8 is packaged with TLS 1.3 support and has significantly switched from Linux kernel 3.10 to Linux kernel 4.18. In addition, support features like kernel live-patching are viable in the RHEL 8.1 point release.
The RHEL OS users benefit from this feature so that the deployment of kernel security fixes takes place without the need for a system reboot. The upgrade changes between RHEL 7 and RHEL 8 can be found on Red Hat’s documentation link. As for Centos Linux 8, its release date already took place in September 2019. Both RHEL 8 and CentOS 8 are highly compatible with the installation and use of the MariaDB server.
MariaDB server installation on RHEL/CentOS
If you already upgraded to RHEL 8 or CentOS 8 OS distributions, your OS environment already has a pre-packaged MariaDB Community Server 10.3. As for the users still exploring RHEL 7 and CentOS 7 OS distributions, their OS environments are pre-packaged with MariaDB server 5.5. As you have noted, there is a big version difference between the MariaDB server on RHEL/CentOS 7 and the one on RHEL/CentOS 8.
Users are encouraged to go with the latest MariaDB server version to not miss out on rich features and upgraded functionalities. The standard installation command for the MariaDB server through the RHEL/CentOS terminal is:
$ sudo yum install mariadb-server
There is more to the installation and setup of the MariaDB server on the RHEL/Centos OS environment than just running a one-line installation command. Before we further indulge with these installation and setup rules, protocol demands that we list down some primary benefits you ought to reap from using the MariaDB server.
MariaDB server 10.4 benefits
The features and functionalities highlighted in the MariaDB server include:
- Authentication enhancement. Each database user is associated with multiple authentication methods.
- Expanded data-at-rest encryption.
- MyRocks, among other additional storage engines.
- A major enhancement from Galera 3 to Galera 4 technology.
- SSL certificates reload functionality without the need for a server restart.
- Common Table Expressions (CTE) and Window functions.
- InnoDB tables instant Alter.
- Performance diagnosis is aided through optimizer trace
- Temporal tables with the inclusion of application-time period, system version, and bitemporal.
- Oracle PL/SQL subset compatibility through SQL_MODE=ORACLE.
MariaDB server 10.4 installation
Whether you are on RHEL/CentOS 7 or RHEL/CentOS 8 OS environment, the first step towards installing and deploying the MariaDB Community Server 10.4 requires “mariadb_repo_setup” script download and usage. The script aids in the configuration of MariaDB repositories for YUM compatibility. Consider the implementation of the following command sequences.
$ sudo yum install wget $ wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup $ chmod +x mariadb_repo_setup $ sudo ./mariadb_repo_setup
Once the MariaDB server repo setup is complete, the succeeding step now allows for installing the MariaDB Community Server and its associated dependencies.
$ sudo yum install MariaDB-server
On RHEL/CentOS 8, there is a high chance of conflicting with OS-vendor packages. A walkthrough from these packages conflicts demands installing dependencies separately and using the “–repo” flag. It helps specify the repository associated with the installation. Consider the implementation of the following command sequences.
$ sudo yum install perl-DBI libaio libsepol lsof boost-program-options $ sudo yum install --repo="mariadb-main" MariaDB-server
MariaDB server configuration and security
Data files and tablespaces in MariaDB Server 10.3/10.4 are written on a file system directory under the name data directory. After the installation of the required packages completes, the provision of this directory will require the execution of the “mysql_install_db” utility. Consider its implementation by the following command.
$ sudo mysql_install_db
Using the “systemctl” command snip, you should be able to launch the MariaDB server systems service as depicted below.
$ sudo systemctl start mariadb.service
If you intend on using the MariaDB server for business-specific governance, meeting such requirements demands that you continue to follow specific security practices. The objective of these practices is met through a series of implemented basic steps. Their successive implementation leads to a healthy MariaDB Community Server deployment.
$ sudo mysql_secure_installation
Testing a MariaDB database connection
You will want to know if your MariaDB installation was a success. You can achieve this step by locally connecting and logging in to the MariaDB service. You can use “mysql”, a MariaDB command-line client.
# mysql -u root -p
Executing the above command as the system’s root user will prompt you for a password before taking you to a usable MariaDB shell.
There is also the possibility of a system user wanting to access and make a database connection from a remote server. The first step will be to edit your firewall configuration to accommodate the needed MySQL service. After you are done with the firewall configuration edits, reload the system firewall.
# firewall-cmd --permanent --add-service=mysql success
# firewall-cmd --reload success
Managing your MariaDB databases
At this stage of the article, you are familiar with the installation and security steps of a MariaDB database. The next instinctive step will be to create a database alongside a database user. A MariaDB shell provides the environment for the creation and execution of the relevant database commands. The shell supports the full use of SQL commands because of its simplicity, interactiveness, and text-based environment. With it, a database server benefits from both local and remote access.
The system’s “root” user is the default MariaDB database administrator. A login attempt to this database requires this system user and the associated user password. The password to use here is the one you configured during the earlier MariaDB installation steps.
# mysql -u root -p
Once you successfully access the MariaDB shell, follow the command syntax highlighted below to create a new MariaDB database. Replace the “database_name” entry with a preferred name for your database.
MariaDB [(none)]> CREATE DATABASE [database_name] CHARACTER SET utf8 COLLATE utf8_general_ci;
An example command with a database name specified would look like the following:
MariaDB [(none)]> CREATE DATABASE fosslindb CHARACTER SET utf8 COLLATE utf8_general_ci;
After you successfully create a database with a name of your choice, the next command step will be to associate this database with a user. With the following command syntax, the only thing you need to replace with your preferred entries is the “database_name”, “username”, and “password” portions of the command syntax.
MariaDB [(none)]> GRANT ALL ON [database_name].* TO '[username]'@'localhost' IDENTIFIED BY '[password]' WITH GRANT OPTION;
Consider the following example code implementation:
MariaDB [(none)]> GRANT ALL ON fosslindb.* TO 'fosslinuser'@'localhost' IDENTIFIED BY 'fosslinpasswd' WITH GRANT OPTION;
Next, MariaDB DBMS needs to acknowledge the changes made.
MariaDB [(none)]> FLUSH PRIVILEGES;
Now that you have a new user created, it is time to log out and log in with that specific user credential.
# mysql -u fosslinuser -p fosslinpasswd
You can verify the creation of your database with the following command. You will be using the “SHOW DATABASES” command on your MariaDB shell.
MariaDB [(none)]> SHOW DATABASES;
The MariaDB enterprise server
The MariaDB Platform commercial support is catered to by the MariaDB Corporation. It is where the MariaDB Enterprise Server resides. A varying range of operating system platforms supports this database server. They include RHEL 7 & 8, and CentOS 7 & 8.
The MariaDB Community Server provided the base for the development of the MariaDB Enterprise Server. However, the Enterprise Server offers high-end enhanced features in comparison to the Community Server. Therefore, expect to reap the following benefits under the MariaDB Enterprise Server platform.
- Enterprise Lifecycle predictable releases.
- Enhanced configuration defaults.
- The MariaDB Enterprise Audit plugin performs better than the MariaDB Audit plugin due to expanded functionality.
- Availability and usage of non-blocking backup functionality through MariaDB Enterprise Backup.
- The MariaDB Enterprise Cluster highlights more superiority over the MariaDB Cluster (Galera) due to its expanded encryption.
The MariaDB’s “mysql_secure_installation” program improves the security of your MariaDB database in the following manner:
- All root accounts are associated with a secure password.
- Gets rid of root accounts remotely accessible from the local host computer system.
- Anonymous user accounts are removed from the database system.
- The test database is removed from the computer system.
The interactive nature of this script takes you through each executable step. The “/etc/my.cnf” file contains MariaDB network configuration directives. Inside this file, trace the “[mysqld]” section. It is this directive that the server listens to and only accepts one value entry. The values could be associated with Hostname, IPv4 address, or IPv6 address.
The “/etc/my.cnf” file takes a single bind-address entry. The selection of a single address is, however, possible on a multiple addresses system. You can also choose to go with all the addresses but no in-betweens, like selecting a handful of preferred addresses. In short, it’s either one address or all addresses, nothing more and nothing less.