Install MariaDB 10.4 on CentOS 8

|
Last Updated:
|
|

This guide will take you through how to install MariaDB 10.4 on CentOS 8 system. As of this writing, MariaDB 10.4 is the current stable (GA) series of MariaDB. You can read more about MariaDB 10.4 features.

Installing MariaDB 10.4 on CentOS 8

Install MariaDB 10.4 YUM Repository

The default CentOS 8 AppStream repo contains MariadDB 10.3 (As of this writing). To install MariaDB 10.4, you need to install its YUM repository.

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

Next, install MariaDB YUM repository signing key.

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

Update your system

dnf update

Install MariaDB 10.4

To install MariaDB 10.4 from the repos created above, you need to disable to AppStream repos which provides MariaDB 10.3 packages.

dnf --disablerepo=AppStream install MariaDB-server MariaDB-client
Dependencies resolved.
=======================================================================================================================================================
 Package                               Arch                          Version                                      Repository                      Size
=======================================================================================================================================================
Installing:
 MariaDB-client                        x86_64                        10.4.8-1.el8                                 mariadb                         12 M
 MariaDB-server                        x86_64                        10.4.8-1.el8                                 mariadb                         26 M
Installing dependencies:
 MariaDB-common                        x86_64                        10.4.8-1.el8                                 mariadb                         87 k
 galera-4                              x86_64                        26.4.2-1.rhel8.0.el8                         mariadb                         13 M

Transaction Summary
=======================================================================================================================================================
Install  4 Packages

Total download size: 51 M
Installed size: 196 M
Is this ok [y/N]:y

If, for some reasons, during the installation you get the error;

Error: 
 Problem: package MariaDB-server-10.4.11-1.el8.x86_64 requires galera-4, but none of the providers can be installed
  - cannot install the best candidate for the job
  - nothing provides libboost_program_options.so.1.66.0()(64bit) needed by galera-4-26.4.3-1.rhel8.0.el8.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

Simply install galera-4 package before running the MariaDB 10.4 installation command above.

dnf install galera-4

After that, rerun the MariaDB installation command;

dnf --disablerepo=AppStream install MariaDB-server MariaDB-client

During the installation, two privileged MariaDB 10.4 user accounts are created.

  • One is root@localhost, it has no password, but you need to be system ‘root’ user to connect e.g sudo mysql
  • The other is mysql@localhost, it has no password either, but you need to be the system ‘mysql’ user to connect.

Running MariaDB

To start MariaDB;

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.4.8 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Thu 2019-10-03 16:08:26 EDT; 1min 45s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 10019 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 11521)
   Memory: 101.9M
   CGroup: /system.slice/mariadb.service
           └─10019 /usr/sbin/mysqld

Verify the MariaDB installed version.

mysql -V
mysql  Ver 15.1 Distrib 10.4.8-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.4 Authentication

As stated above, two secure accounts are created during the installation of MariaDB 10.4. 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 10.4 Authentication.

That is all on our guide on how to install MariaDB 10.4.

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

Install MySQL 8 on CentOS 8

Install MySQL 8 on Debian 10 Buster

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

2 thoughts on “Install MariaDB 10.4 on CentOS 8”

  1. Not working, i got error like this:

    [root@noiseme ~]# yum –disablerepo=AppStream install MariaDB-server MariaDB-client
    Last metadata expiration check: 0:02:56 ago on Wed 25 Dec 2019 06:42:06 PM UTC.
    Error:
    Problem: package MariaDB-server-10.4.11-1.el8.x86_64 requires galera-4, but none of the providers can be installed
    – cannot install the best candidate for the job
    – nothing provides libboost_program_options.so.1.66.0()(64bit) needed by galera-4-26.4.3-1.rhel8.0.el8.x86_64
    (try to add ‘–skip-broken’ to skip uninstallable packages or ‘–nobest’ to use not only best candidate packages)

    Reply
    • Hello Fahri,
      try to install galera-4;
      dnf install galera-4
      Then;
      dnf –disablerepo=AppStream install MariaDB-server MariaDB-client

      Reply

Leave a Comment