April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Installing MariaDB on CentOS Linux 7.5

MariaDB is an open source relational database management system that is backwards compatible and replaces MySQL with binary. It was developed by some of MySQL’s original developers and many in the community. With the release of CentOS 7, MySQL was replaced by MariaDB as the default database system.

If for any reason you need to install MySQL, check out how to install MySQL on the CentOS 7 tutorial. If your application does not have any specific requirements, you should stick with MariaDB, the default database system in CentOS 7.

In this tutorial, we will show you how to install the latest version of MariaDB on CentOS 7 using the official MariaDB repository. The MariaDB server version provided in the default CentOS repository is version 5.5 and is not the latest stable version of MariaDB.

Install MariaDB

At the time of this writing, the latest version of MariaDB is version 10.3.

Create a repository file called MariaDB.repo and add the following:

/etc/yum.repos.d/MariaDB.repo

# MariaDB 10.3 CentOS repository list – created 2018-05-27 07:02 UTC 
# http://downloads.mariadb.org/mariadb/repositories/ 
[mariadb] 
name = MariaDB 
baseurl = http://yum.mariadb.org/ 10.3/centos7-amd64 
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 
gpgcheck=1

If you need to install any other version of MariaDB, generate a repository for your desired version of MariaDB on this page (https://downloads.mariadb.org/mariadb/repositories/).

We will use yum to install the MariaDB server and client packages, just like other CentOS packages, by typing the following command:

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 <package-signing-key@mariadb.org>” 
Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db 
From : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

Type y and press Enter.

After the installation is complete, enable and start the MariaDB service:

Sudo systemctl enable mariadb 
sudo systemctl start mariadb

Once the MySQL service starts, we can check its status by entering the following:

Sudo systemctl status mariadb

Sample output:

? mariadb.service – MariaDB 10.3.7 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/

And print the MariaDB server version, which contains:

Mysql -V

Mysql Ver 15.1 Distrib 10.3.7-MariaDB, for Linux (x86_64) using readline 5.1

Protecting MariaDB security

Run the mysql_secure_installation command to improve MariaDB installation security:

Sudo mysql_secure_installation

The script prompts you to set the root password, remove the anonymous user, restrict the root user’s access to the local computer, and delete the test database. All steps are detailed and it is recommended to answer “yes” (yes) to all questions.

Connect to MariaDB from the command line

To connect to the MariaDB server through the terminal, we will use the MariaDB client.

You can log in to the MariaDB server as root by typing:

Mysql -u root -p

You will be prompted to enter the previously set root password when running the mysql_secure_installation script.

Once you enter the password, you will see the MariaDB shell as follows:

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

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>