Install MariaDB 10.x on Rocky Linux 8

|
Last Updated:
|
|

This guide will take you through how to install MariaDB 10.x on Rocky Linux 8 system. As of this writing, MariaDB 10.5.10 is the current stable (GA) series of MariaDB based on MariaDB releases page.

You can read more about MariaDB 10.5 on its release notes page.

Installing MariaDB 10.x on Rocky Linux 8

The default Rocky Linux 8 AppStream repos provides MariadDB 10.3 (As of this writing).

Therefore, if you need to install say, the latest stable release version of MariaDB, 10.5.10, on Rocky Linux, then you have to install MariaDB YUM repos.

Install MariaDB 10.x YUM Repository on Rocky Linux

To install MariaDB 10.5.10, for instance, you need to install MariaDB YUM repository.

cat << EOL > /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/rhel8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
module_hotfixes=1
EOL

Next, install MariaDB YUM repository signing key.

rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

Install MariaDB 10.x

To install MariaDB 10.4 from the repos created above, simply run the command below;

dnf install MariaDB-server MariaDB-client

Running MariaDB on Rocky Linux 8

To start MariaDB service;

systemctl start mariadb

To enable MariaDB to run on system boot;

systemctl enable mariadb

To check the status of MariaDB;

systemctl status mariadb
● mariadb.service - MariaDB 10.5.10 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Thu 2021-06-17 13:53:58 EAT; 3min 48s ago
     Docs: man:mariadbd(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 47394 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 47369 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-env>
  Process: 47367 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 47379 (mariadbd)
   Status: "Taking your SQL requests now..."
    Tasks: 9 (limit: 4938)
   Memory: 103.8M
   CGroup: /system.slice/mariadb.service
           └─47379 /usr/sbin/mariadbd

Jun 17 13:53:56 localhost.localdomain mariadbd[47379]: 2021-06-17 13:53:56 0 [Note] InnoDB: 10.5.10 started; log sequence number 45118; transaction id 20
Jun 17 13:53:56 localhost.localdomain mariadbd[47379]: 2021-06-17 13:53:56 0 [Note] Plugin 'FEEDBACK' is disabled.
Jun 17 13:53:56 localhost.localdomain mariadbd[47379]: 2021-06-17 13:53:56 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Jun 17 13:53:56 localhost.localdomain mariadbd[47379]: 2021-06-17 13:53:56 0 [Note] InnoDB: Buffer pool(s) load completed at 210617 13:53:56
Jun 17 13:53:56 localhost.localdomain mariadbd[47379]: 2021-06-17 13:53:56 0 [Note] Server socket created on IP: '::'.
Jun 17 13:53:58 localhost.localdomain mariadbd[47379]: 2021-06-17 13:53:58 0 [Note] Reading of all Master_info entries succeeded
Jun 17 13:53:58 localhost.localdomain mariadbd[47379]: 2021-06-17 13:53:58 0 [Note] Added new Master_info '' to hash table
Jun 17 13:53:58 localhost.localdomain mariadbd[47379]: 2021-06-17 13:53:58 0 [Note] /usr/sbin/mariadbd: ready for connections.
Jun 17 13:53:58 localhost.localdomain mariadbd[47379]: Version: '10.5.10-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
Jun 17 13:53:58 localhost.localdomain systemd[1]: Started MariaDB 10.5.10 database server.

Verify the MariaDB installed version.

mysql -V
mysql  Ver 15.1 Distrib 10.5.10-MariaDB, for Linux (x86_64) using readline 5.1

Securing MariaDB

MariaDB comes with a default security script, mysql_secure_installation that is used to improve the security of MariaDB installation by:

  • 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.

Simply run the command below to launch the script.

mysql_secure_installation

MariaDB 10.5 Authentication

MariaDB is installed with two secure accounts of MariaDB 10.5, root@localhost and mysql@localhost.

The root@localhost uses both the unix_socket and the mysql_native_password authentication plugins.

Unix_socket plugins works when connection to MariaDB is made from the localhost as a root user. You can simply login running the command (as root or with sudo);

mysql
mysql -u root

The mysql_native_password plugin is used as a failover for the unix_socket plugin. However, the account has an invalid password. To enable password authentication, you need to login to MariaDB as root user as shown above and set the password.

mysql
set password = password("P@sSw0Rd123");

This re-enables the MariaDB password authentication.

Set Native Password Authentication Method as Default

If you need to change the unix_socket plugin authentication to the msqyl_native_password authentication method, simply login to MariaDB and change the authentication plugin for root user.

mysql
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("MyPQQSSword");

Next time you try to login without specifying the password, login will fail.

sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Read more about authentications on MariaDB Authentication plugins.

That is all on our guide on how to install MariaDB 10.x.

You can now use MariaDB as you wish.

Other Tutorials

You can check our other guides on MariaDB/MySQL installations by following the links below;

Install MariaDB 10 on Debian 10 Buster

Install MariaDB 10.4 on Ubuntu 18.04/Debian 9

Install MariaDB 10.3 on CentOS 7

Install MariaDB 10.3 on Fedora 30

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment