MariaDB Server is one of the most popular open source relational databases. It’s made by the original developers of MySQL and guaranteed to stay open source. It is part of most cloud offerings and the default in most Linux distributions.

The latest version of MariaDB is version 10.4.12. If you need to install any other version of MariaDB, head over to the MariaDB repositories page, and generate a repository file for a specific MariaDB version.

To install MariaDB 10.4.12 on CentOS 7, follow these steps:

  1. The first step is to Enable the MariaDB repository. Create a repository file named MariaDB.repo and add the following content:
    /etc/yum.repos.d/MariaDB.repo

    # MariaDB 10.4 CentOS repository list - created 2020-02-19 02:49 UTC 
    # http://downloads.mariadb.org/mariadb/repositories/
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.4/centos7-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1

  2. Install the MariaDB server and client packages using yum, same as other CentOS package:

    sudo yum install MariaDB-server MariaDB-client

    Yum may prompt you to import the MariaDB GPG key:

    Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    Importing GPG key 0x1BB943DB:
     Userid     : "MariaDB Package Signing Key "
     Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db
     From       : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

    Type y and hit Enter.

  3. Once the installation is complete, enable MariaDB to start on boot and start the service:

    sudo systemctl enable mariadbsudo systemctl start mariadb
  4. To verify the installation check the MariaDB service status by typing:

    sudo systemctl status mariadb
    ● mariadb.service - MariaDB 10.4.12 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: inactive (dead)
         Docs: man:mysqld(8)
               https://mariadb.com/kb/en/library/systemd/
  5. The last step is to run the mysql_secure_installation script which will perform several security related tasks:

    sudo mysql_secure_installation

    The script will prompt you to set up the root user password, remove the anonymous user, restrict root user access to the local machine, and remove the test database.

    All steps are explained in detail and it is recommended to answer Y (yes) to all questions.

Connect to MariaDB from the command line

To connect to the MariaDB server through the terminal as the root account type:

mysql -u root -p

You will be prompted to enter the root password you have previously set when the mysql_secure_installation script was run.

Once you enter the password you will be presented with the MariaDB shell as shown below:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.12-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.
  • No labels