How to install MariaDB 10.2 on CentOS 6

by Daniel Pham
Published: Updated:

In this article, I will show you how to install MariaDB 10.2 on CentOS 6.

Server requirements

Here are the minimum requirements for the server, I have used a virtual server with such requirements.

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

Added MariaDB repository

The first step is to add MariaDB repository to CentOS 6 server.

You can find more information on how to add a repository here.

Please copy and paste the code below into your terminal. Note that there are no spaces at the beginning of the lines between EOF characters.

cat > /etc/yum.repos.d/MariaDB.repo <<"EOF"
# MariaDB 10.2 CentOS repository list - created 2018-03-28 06:30 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

After adding the repository, you type below command to update new packages from MariaDB repository.

yum update -y

Install MariaDB in CentOS 6

To install MariaDB server on CentOS 6, type the following command.

yum install MariaDB-server MariaDB-client -y
How to install MariaDB 10.2 on CentOS 6
Install MariaDB 10.2 on CentOS 6.

You wait a while for the installation to complete. Then, type the following two commands to enable the service when you reboot and start the service.

chkconfig mysql on
service mysql start

You can then type the following command to check the mysql service status.

service mysql status

And 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 IPtables

If you only use MariaDB for the local host, you can skip this section.

If you want to open mysql port 3306 for other servers that can connect to and use the database, then type the following commands.

How to install MariaDB 10.2 on CentOS 6
Set rules to open port 3306 in IPtables.
iptables -I INPUT 1 -m tcp -p tcp --dport 3306 -j ACCEPT
iptables-save > /etc/sysconfig/iptables

And to check the status of the IPtables rule table, you type the command below.

iptables -L

Check MariaDB run

Now on the terminal window, type the following command to login to the mysql service. Remember to type the root password you set.

How to install MariaDB 10.2 on CentOS 6
Login to mysql on CentOS 6.
mysql -u root -p

If your logint succeeds as shown in the image above, you have successfully installed MariaDB 10.2 on CentOS 6. And now you can use the database server.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Gerard
Guest
4 years ago

Very helpful, thank you!
I had an old mysql install and had to rename the existing data directory /var/lib/mysql. Otherwise the new mariadb install tried to work with existing files and fell over.

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.