SystemMen - 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
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.
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.
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.
«« Nginx redirect a location to another domainHow to install rkhunter on CentOS 6 »»
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.