How to install MariaDB 10.2 in CentOS 7


SystemMen - This article will walk you through how to install MariaDB 10.2 in CentOS 7. MariaDB is an improved version of MySQL. By default, when you install MariaDB in CentOS 7, it will install version 5.5.

Server requirements

Here is the minimum configuration required that I use.

  • OS: CentOS 7.4.1708 (Core) 64 bit.
  • RAM: over 1GB memory.
  • HDD: over 5GB free space. Maybe you need more for store databases.
  • User: root.
  • IP: set static ip, ex: 192.168.56.4.

Added MariaDB repository

First, we will add a MariaDB repository to CentOS 7, which is based on information from the MariaDB home page.

You type the following command. Note that there are no spaces before each line in the command below.

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

After adding the repository, you may want to update the packages.

yum update -y

Install MariaDB in CentOS 7

Now, type the following command to install MariaDB in CentOS 7.

yum install MariaDB-server MariaDB-client -y
how-to-install-mariadb-10-2-in-centos-7-01 How to install MariaDB 10.2 in CentOS 7
Add repository and install MariaDB 10.2 in CentOS 7.

Installation may take 5 to 10 minutes depending on your internet connection condition.

systemctl enable mariadb
systemctl start mariadb

Interestingly, if you are familiar with CentOS 6. You can still use the command below to check the service and both of these commands work equally.

service mysql status
service mariadb status

Finally, you need to set up the initial security for the MariaDB server using the following command. You will answer some basic questions, set the root password (if not set).

mysql_secure_installation

Set rules in Firewalld

If you are installing MariaDB all-in-one then you can skip this step, because MariaDB will use as in LAN. If you want to allow other machines to connect to the MariaDB server on this machine then you need to set up the rule in the Firewalld.

You run the following commands in turn and after each command if the success line appears then you type correctly.

how-to-install-mariadb-10-2-in-centos-7-02 How to install MariaDB 10.2 in CentOS 7
Setup rules in Firewalld for MariaDB’s service.
firewall-cmd --permanent --add-service=mysql
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --reload

Check out the MariaDB server

Now you can type the following command to log into the MariaDB server to see how the results. Type root’s password.

mysql -u root -p
how-to-install-mariadb-10-2-in-centos-7-03 How to install MariaDB 10.2 in CentOS 7
Login to MariaDB server.

If you can login to the window as shown in the image above, congratulations on installing MariaDB 10.2 in CentOS 7 successfully. Now you can start creating new databases and use them.

«« »»