MySQL 5.6 & 5.7 Installation on Redhat and Centos 6,7 Linux

Mysql Oracle

Oracle MySQL 5.6 and 5.7 stands out as the most mature version with the highest performance in MySQL’s history. Also the third release after Oracle’s acquisition. In this article, we will install and configure Oracle MySQL 5.6 and 5.7 on Linux and Red Hat Enterprise Linux 6,7 and 7.

If you want to run the best new versions, you can use the MySQL Yum repository here. Download and install the repository package.

rpm -Uvh mysql-community-release-el6-4.noarch.rpm

rpm -Uvh mysql57-community-release-el7-7

installing 5.6 on Oracle Linux 6

yum install mysql mysql-server -y

installing 5.7 on Oracle Linux 7

yum install mysql-community-server -y

Mysql for workbench installation

installing 5.6 on Oracle Linux 6

yum install mysql-workbench -y

installing 5.7 on Oracle Linux 7

yum install mysql-workbench-community -y

Start the MySQL Service “mysqld

chkconfig mysqld on

service mysqld start

  • The arrow result should return ok to here.

Mysql root password is created.

/usr/bin/mysqladmin -u root password ‘New Password’

/usr/bin/mysqladmin -u root -h rhce1.localdomain password ‘New Password’

the MySQL daemon test:
cd /usr ; /usr/bin/mysqld_safe &

MySQL daemon test with
cd /usr/mysql-test ; perl

The screenshot should look like this;

 Linux 7 Command

systemctl enable mysqld

systemctl start mysqld

Selinux Configuration

setenforce Permissive


Create Directories

mkdir -p /u01/data
mkdir -p /u01/log_bin
mkdir -p /u01/tmpdir
chown -R mysql:mysql /u01
chmod -R 755 /u01

Stop Mysql Service

Linux 6 = service mysqld stop

Linux 7 = systemctl stop mysqld

Edit the “/etc/my.cnf”


Start Mysql Service

Linux 6 = service mysqld start

Linux 7 = systemctl start mysqld

Create Database

$ mysql –user=root –password

Create a new database command.

mysql> create database mydatabase;

mysql> show databases;

| Database           |
| information_schema |
| mydatabase         |
| mysql              |
3 rows in set (0.00 sec)

To switch between databases;

mysql> use mydatabase;

New connections

$ mysql –user=root –database=mydatabase –password

mysql> select database();
| database() |
| mydatabase |
1 row in set (0.00 sec)

SElinux Config

Default installation Policy

semanage port -a -t mysqld_port_t -p tcp 3306
semanage fcontext -a -t mysqld_etc_t “/etc/my.cnf”
semanage fcontext -a -t mysqld_log_t “/etc/mysqld.log”

Using the commands “semanage” and “restorecon” on our server
we give permissions to our sharing directory.

semanage fcontext -a -t mysqld_db_t “/u01/data(/.)?”
restorecon -Rv /u01/data

semanage fcontext -a -t mysqld_db_t “/u01/log_bin(/.)?”
restorecon -Rv /u01/log_bin