An objective for the Red Hat RH254 (RHCE) course is to be able to install and configure the MariaDB. In the module we look at the installation and initial configuration.
MariaDB is an open source Relational Database Management System or RDBMS and, of course, we are going to need to understand that term. Firstly, let’s forget the R and works with DBMS. A database management system allows for the storage, management and retrieval of data. The reality often being, lots of data, more than we would want with flat files. We can now bring onto the stage the R for relational. A relational database was first suggested in 1970 by Edgar Codd, pictured. The RDBMS structure that he outlined should have a set of tables comprising of rows or records. Each row representing a single record in the table. Each row will consists of columns or fields for data storage. A key feature to protect against duplicate entries is the Primary Key index which is required to be unique to the record in the table. Often this Primary Key is configured on the ID column such as the EmployeeID or PurchaseID. MariaDB is a relational database along with other examples including MySQL, Oracle, DB2, PostgreSQL and Microsoft SQL Server.
What is MariaDB
MariaDB is relatively new to the RDBMS market place having been forked from the popular MySQL database owned now by Oracle. The fork was created by Michael “Monty” Widenius on 2011 to ensure the continuity of open-source MySQL in the event that Oracle do not develop the product further.
The current version of MariaDB that ships with RHEL 7.1 is 5.5.41 and is compatible with MySQL 5.5
# yum info mariadb-server
The very latest version of MariaDB is version 10 but that is not representative of a big jump just a change in numbering after the 5.5 release.
We will, in most circumstances, where we want the database server and client will install 3 packages that are explained in the following table:
Provides MariaDB client programs and a configuration files
Contains the database server and tools
Essential library files for client and server
To install the database client and server:
# yum install mariadb mariadb-server mariadb-libs
To verify the installed packages:
# yum list installed | grep ^mariadb
Adding a firewall rule
Using a default install of RHEL 7.1 the firewall will be implemented using firewalld and an explicit rule must be added to allow access to the database server if it is going to be accessed from the network. A consideration is that some MariaDB installations will not
require access from anything outside of the localhost. To allow access from the network to MariaDB:
# firewall-cmd –permanent –add-service mysql
# firewall-cmd –reload
# firewall-cmd –list-services
Enable MariaDB Service
We should now enable the service so that it may start with the system. This is managed though the systemd unit file mariadb.service. In the following commands we both enable and start the service:
# systemctl enable mariadb.service
# systemctl start mariadb.service
With the service running and enable and the firewall in place we should now run the basic set-up of the server.
The basic security of MariaDb is manage by running the command mysql_secure_installation, this runs an interactive script prompting you as the administrator through commonly configured options.
As the script runs you will be prompted with the following questions:
Enter the current root password <this will be blank>
Set root password <choose Y and enter Password1 twice>
Remove anonymous users <Choose Y>
Disallow root login remotely <Choose Y>
Remove test database and access to it <Choose Y>
Reload privilege tables now <Choose Y>
This is a good start and becomes an easy way to set the root password and allow access as root only from the localhost so that network users cannot log in a the privilged account.
Note: The MariaDB root account is not the same as the Linux root account and the password should ideally be different.