MariaDB gives improved performance over MySQL and offers better storage engines, a larger and faster connection pool, speed and replication improvements. MariaDB is now the popular Database for CMS tools such as WordPress, Joomla, and Drupal. Apps like phpMyAdmin work out of the box on it.
In this tutorial, we learn how to install MariaDB on Rocky Linux 8.
Step 1: Add Repository for MariaDB on Rocky Linux
The Rocky Linux AppStream repository comes with MariaDB. The default version available is MariaDB 10.3. The latest version available on the Rocky AppStream repository is MariaDB 10.5, as of writing this tutorial.
To list the available MariaDB version, type:
$ sudo dnf module list mariadb
Last metadata expiration check: 0:00:10 ago on Fri 06 Aug 2021 11:54:15 PM UTC. Rocky Linux 8 - AppStream Name Stream Profiles Summary mariadb 10.3 [d] client, galera, server [d] MariaDB Module mariadb 10.5 client, galera, server [d] MariaDB Module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Note: To go with the default version (currently 10.3), no need to add the official repository - directly go to step 2. For MariaDB 10.5, enable its module version (sudo dnf module enable mariadb:10.5) and proceed to step 2.
MariaDB's official repository has the latest version. Normally it takes some time to reach Rocky Linux AppStream.
To install the latest version on the MariaDB repository, first create a MariaDB repo file.
$ sudo vi /etc/yum.repos.d/mariadb.repo
Add the below lines to the repo file - which you can generate using the MariaDB repository configuration tool.
# MariaDB 10.6 RedHat repository list [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
Then save and exit from the file.
Step 2: Install MariaDB on Rocky Linux
Once the MariaDB repository is added, install MariaDB Server and client using the following command.
$ sudo dnf install mariadb-server mariadb
To start MariaDB service, type:
$ sudo systemctl start mariadb
Check the status of MariaDB service, type:
$ sudo systemctl status mariadb
If the MariaDB service is running, you can enable it to start at system boot.
$ sudo systemctl enable mariadb
Step 3: Secure MariaDB installation
Fresh MariaDB installation is not secure. MariaDB package comes with a script preinstalled which helps to improve the security of your database server.
The new installation on MariaDB has root password blank. This script allows to set a new root password, remove anonymous users, disallow root remote login, remove test database.
To start the script, type:
$ sudo mysql_secure_installation
From MariaDB 10.5.2,
mysql_secure_installation is the symlink, and
mariadb-secure-installation the binary name.
If you get this error "sudo: mysql_secure_installation: command not found" try use this script
Step 4: Verify the installation
Now we can verify the installation by login into the MariaDB shell using the root user.
$ sudo mysql -u root -p
Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 13 Server version: 10.6.4-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
The output shows we have installed MariaDB 10.6 version and got a shell to manage database operations.
In this tutorial, we learned how to install MariaDB on Rocky Linux 8. We installed the latest version MariaDB 10.6 from the official repository.
Thanks for reading, please lets us know your suggestions in the below comment section.