Join to Get Free Linux Server Hacks & cPanel Tips

Install MySQL 5.6 on CentOS 7 / RHEL 7

Install MySQL 5.6 on CentOS 7 / RHEL 7
4.5 (90%) 4 votes

In this tutorial we will explore a quick and simple way on how to install MySQL 5.6 on CentOS 7 / RHEL 7. Previously we already wrote about how to install MySQL Server 5.6 on CentOS 6 / RHEL 7.

CentOS and RHEL 7 comes with MariaDB by default. MariaDB is the database standart daemon used to replace the old MySQL Server from Oracle. MariaDB was created by the founder of the original MySQL Server, and it improves SQL query and the database server performance a lot than traditional MySQL versions.

However, there are still companies who use MySQL Server as the default database server. This was the case in one of our dedicated servers from one of our customers. He requested to have only MySQL 5.6 on CentOS 7, and so we did. Here is the procedure.

Installing MySQL 5.6 on CentOS 7

First, ensure your system is up to date:

yum update -y

Once all your packages are updated, let’s continue with the MySQL Server Community Edition installation.

Remove MariaDB

Run this commands to remove MariaDB from your server:

yum remove mariadb mariadb-server -y

Install MySQL Community Repository

In order to install MySQL 5.6 on CentOS 7 you need to download and install the official MySQL community repository. Run this command:

rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

Install MySQL Server

Then use yum to install MySQL client and MySQL Server as you see below:

yum install mysql mysql-server

Start MySQL and Enable Auto-Start after booting

Start your MySQL 5.6 server and make sure you enable it to start during the boot process:

systemctl start mysqld
systemctl enable mysqld

Secure MySQL Server

You are almost ready, now let’s run the MySQL security script to ensure your server gets hardened. For this we will use the mysql_secure_installation script that must be run after every MySQL server installation. Simply run this script as root:

mysql_secure_installation

Check your MySQL Client and Server are Working

Run this commands:

[root@server.nixcp.com:~]mysql -V
mysql Ver 14.14 Distrib 5.6.35, for Linux (x86_64) using EditLine wrapper
[root@server.nixcp.com:~]

Try to connect to your MySQL server as root:

mysql -u root -p
[root@server.nixcp.com:~]mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 249979
Server version: 5.6.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
MySQL 5.6 on CentOS 7 / RHEL 7
Screenshot of MySQL 5.6 on CentOS 7 / RHEL 7

That’s all, at this point you should have your MySQL 5.6 on CentOS 7 / RHEL 7 working without problems.