MariaDB database server is a high-performance, robust, and feature-rich relational database server that provides an SQL shell prompt for database management. The database server was created by developers who came up with MySQL soon after the acquisition of MySQL by Oracle in 2009. Simply put, it’s a fork on MySQL.
MariaDB is available under the GPL v2 and is popular for its scalability, flexibility, and scalability. It provides a wide array of plugins, storage engines such as InnoDB, TokuDB, and CONNECT, Galera clustering, faster replication among other cool features & tools that enhance its performance. MariaDB is an integral component in the LAMP stack is used by giant companies such as Google Inc and Wikipedia.
MAriaDB comes in two editions: The MariaDB community edition which is free to download and use and MariaDB Enterprise Server.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related MariaDB databases queries on any Linux distribution.
In this context, we shall look into how you can install MariaDB on Rocky Linux 8.
Steps to install MariaDB on Rocky Linux ?
1. Add the latest MariaDB repository
The AppStream repository, by default, provides MariaDB 10.3 which, currently, is not the latest version.
You can verify the versions provided by the repository by execute the below command:
$ sudo dnf module list mariadb
To install the latest version, which by the time of writing is MariaDB 10.6, you need to add the repository manually on your system.
So, create a repository file:
$ sudo vim /etc/yum.repos.d/mariadb.repo
Next, paste the lines shown to add the repository and save the changes:
name = MariaDB
baseurl = http://yum.mariadb.org/10.6/rhel8-amd64
Once added, update Rocky Linux packages and repositories with the below command:
$ sudo dnf update
Once you have updated your system, you are now ready to install the MariaDB server.
2. Install MariaDB database server
Here, install MariaDB database server and client using the command:
$ sudo dnf install mariadb-server mariadb
This command installs the MariaDB server and client alongside other dependencies. During the installation, press 'Y' when prompted to import the MariaDB GPG key.
3. Enable and Start MariaDB database server
Now that MariaDB is successfully installed, you need to enable it to start on boot time without intervention with the below command:
$ sudo systemctl enable mariadb
With the MariaDB database server enabled on boot, start the MariaDB daemon:
$ sudo systemctl start mariadb
You can confirm the status of the database server as follows:
$ sudo systemctl status mariadb
To log in to MariaDB, execute:
$ sudo mysql -u root -p
When prompted for a password, just press ENTER to access the MariaDB shell.
4. Secure MariaDB database server
As per the preceding step, The database server does not have a root password configured. Virtually anyone can access the database server, and this presents a huge security risk for the system. We will go the extra mile and secure the database server by setting the root password and performing additional tweaks.
- To do so, run the script shown:
- $ sudo mariadb-secure-installation
- When prompted to enter the current root password, just press ENTER and switch to unix_socket authentication by pressing 'Y'.
- Then press 'Y' to change the root password and provide a strong password.
- For the remaining prompts, press 'Y' to tweak the database server to the recommended settings. This provides fundamental security from breaches. By doing so, you get rid of anonymous users, block remote root login, and purge the test database which shouldn't be in the production environment.
- Next time when you log in to the MariaDB shell, you will be prompted for the root password.
[Need help in setting up MariaDB on your Linux System ? We are here to help you. ]