Hi everyone, in this short article I will show how to install MySQL Database Server 5.7 on Oracle Linux 6.8. I will install it from the rpm files.

First, let’s create the mysql group and the mysql user and assign it to the group:
[root@mysql-master ~]# groupadd mysql -g 1001
[root@mysql-master ~]# useradd -g 1001 -u 1001 mysql
Let’s check that it came out right:
[root@mysql-master ~]# id mysql
uid=1001(mysql) gid=1001(mysql) groups=1001(mysql)
Now we need to set a password for the mysql user:
[root@mysql-master ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
In this case I am using the commercial version of MySQL Database Server, but the procedure is exactly the same for the community version, which you can download here.
We unzip the file that contains the MySQL Database Server rpm packages:
[root@mysql-master mysql]# unzip MySQL\ Database\ 5.7.9\ RPM\ for\ Oracle\ Linux\ \ RHEL\ 6\ x86\ \(64bit\)\ \(Patchset\).zip
Archive: MySQL Database 5.7.9 RPM for Oracle Linux RHEL 6 x86 (64bit) (Patchset).zip
extracting: mysql-commercial-devel-5.7.9-1.1.el6.x86_64.rpm
extracting: mysql-commercial-libs-5.7.9-1.1.el6.x86_64.rpm
extracting: mysql-commercial-test-5.7.9-1.1.el6.x86_64.rpm
extracting: mysql-commercial-common-5.7.9-1.1.el6.x86_64.rpm
extracting: mysql-commercial-server-5.7.9-1.1.el6.x86_64.rpm
extracting: mysql-commercial-embedded-5.7.9-1.1.el6.x86_64.rpm
extracting: mysql-commercial-embedded-devel-5.7.9-1.1.el6.x86_64.rpm
extracting: mysql-commercial-libs-compat-5.7.9-1.1.el6.x86_64.rpm
extracting: mysql-commercial-client-5.7.9-1.1.el6.x86_64.rpm
extracting: README.txt
Adjust the /etc/hosts file with your IP address and hostname:
[root@mysql-master mysql]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.101 mysql-master.localdomain mysql-master
Before installing the MySQL packages we downloaded, let’s check whether there is any other MySQL Database Server installation on our server:
[root@mysql-master mysql]# rpm -qa|grep mysql
mysql-libs-5.1.73-7.el6.x86_64
As we can see, we have mysql-libs version 5.1.73, and it will conflict with the MySQL Database Server 5.7 installation, so let’s remove it:
[root@mysql-master mysql]# yum erase mysql-libs-5.1.73-7.el6.x86_64
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.73-7.el6 will be erased
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64
......
--> Running transaction check
---> Package crontabs.noarch 0:1.10-33.el6 will be erased
---> Package sysstat.x86_64 0:9.0.4-31.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================================================================
Removing:
mysql-libs x86_64 5.1.73-7.el6 @anaconda-OracleLinuxServer-201605181719.x86_64/6.8 4.0 M
Removing for dependencies:
cronie x86_64 1.4.4-15.el6_7.1 @anaconda-OracleLinuxServer-201605181719.x86_64/6.8 174 k
......
redhat-lsb-graphics x86_64 4.0-7.0.2.el6 @anaconda-OracleLinuxServer-201605181719.x86_64/6.8 0.0
redhat-lsb-printing x86_64 4.0-7.0.2.el6 @anaconda-OracleLinuxServer-201605181719.x86_64/6.8 0.0
sysstat x86_64 9.0.4-31.el6 @anaconda-OracleLinuxServer-201605181719.x86_64/6.8 826 k
Transaction Summary
=====================================================================================================================================================================================================
Remove 11 Package(s)
Installed size: 15 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : redhat-lsb-4.0-7.0.2.el6.x86_64 1/11
Erasing : redhat-lsb-compat-4.0-7.0.2.el6.x86_64 2/11
......
Verifying : 2:postfix-2.6.6-6.el6_7.1.x86_64 9/11
Verifying : redhat-lsb-graphics-4.0-7.0.2.el6.x86_64 10/11
Verifying : redhat-lsb-4.0-7.0.2.el6.x86_64 11/11
Removed:
mysql-libs.x86_64 0:5.1.73-7.el6
Dependency Removed:
cronie.x86_64 0:1.4.4-15.el6_7.1 cronie-anacron.x86_64 0:1.4.4-15.el6_7.1 crontabs.noarch 0:1.10-33.el6 postfix.x86_64 2:2.6.6-6.el6_7.1
redhat-lsb.x86_64 0:4.0-7.0.2.el6 redhat-lsb-compat.x86_64 0:4.0-7.0.2.el6 redhat-lsb-core.x86_64 0:4.0-7.0.2.el6 redhat-lsb-graphics.x86_64 0:4.0-7.0.2.el6
redhat-lsb-printing.x86_64 0:4.0-7.0.2.el6 sysstat.x86_64 0:9.0.4-31.el6
Complete!
Now we can install the packages needed for MySQL 5.7. Install them in the following order and there will be no incompatibilities because of dependencies.
[root@mysql-master mysql]# rpm -ivh mysql-commercial-common-5.7.9-1.1.el6.x86_64.rpm
warning: mysql-commercial-common-5.7.9-1.1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-commercial-common########################################### [100%]
[root@mysql-master mysql]# rpm -ivh mysql-commercial-libs-5.7.9-1.1.el6.x86_64.rpm
warning: mysql-commercial-libs-5.7.9-1.1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-commercial-libs ########################################### [100%]
[root@mysql-master mysql]# rpm -ivh mysql-commercial-libs-compat-5.7.9-1.1.el6.x86_64.rpm
warning: mysql-commercial-libs-compat-5.7.9-1.1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-commercial-libs-c########################################### [100%]
[root@mysql-master mysql]# rpm -ivh mysql-commercial-client-5.7.9-1.1.el6.x86_64.rpm
warning: mysql-commercial-client-5.7.9-1.1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-commercial-client########################################### [100%]
[root@mysql-master mysql]# rpm -ivh mysql-commercial-server-5.7.9-1.1.el6.x86_64.rpm
warning: mysql-commercial-server-5.7.9-1.1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-commercial-server########################################### [100%]
Check that the /var/lib/mysql directory belongs to the mysql user, otherwise run the following:
[root@mysql-master mysql]# chown -R mysql:mysql /var/lib/mysql
Check the /etc/my.cnf file to see the value of the datadir parameter:
[root@mysql-master ~]# grep datadir /etc/my.cnf
datadir=/var/lib/mysql
With this parameter, initialize MySQL Database Server through the mysqld daemon as the mysql user and follow the log in the file /var/log/mysqld.log.
[mysql@mysql-master ~]$ mysqld --initialize --datadir=/var/lib/mysql
After initialization, MySQL generates a random password:
[root@mysql-master mysql]# tail -n 2 /var/log/mysqld.log
2017-02-14T23:46:55.173234Z 0 [Warning] CA certificate ca.pem is self signed.
2017-02-14T23:46:55.500197Z 1 [Note] A temporary password is generated for root@localhost: ?GZ*=u2uHMpa
With this password (?GZ*=u2uHMpa), let’s run the procedure below to change it and set some security options:
[mysql@mysql-master ~]$ mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: N
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N
... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.
All done!
Connect to MySQL Database Server using the mysql client and the new password you set:
[mysql@mysql-master ~]$ mysql -u root -poracle
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.9-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2015, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
To check the status, stop and start MySQL Database Server, run:
[root@mysql-master ~]# service mysqld status
mysqld (pid 774) is running...
[root@mysql-master ~]# service mysqld stop
Stopping mysqld: [ OK ]
[root@mysql-master ~]# service mysqld start
Starting mysqld: [ OK ]
Let’s check whether MySQL is configured to start automatically when the server boots:
[root@mysql-master ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
We can see that the mysqld daemon will not start in any of the Linux runlevels, so let’s configure it to do so:
[root@mysql-master ~]# chkconfig mysqld on
Let’s also add an exception to our firewall so that MySQL port 3306 is open for external access:
[root@mysql-master ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
[root@mysql-master ~]# iptables -I INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
[root@mysql-master ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@mysql-master ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
Let’s also disable SELinux to avoid problems:
[root@mysql-master ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@mysql-master ~]# setenforce 0
That’s all for today, folks. Installing MySQL Database Server is quite simple. Little by little I will present and explore this database a bit more. If you have questions, suggestions or constructive criticism, just leave a comment.
Regards,
Franky

Parabéns pelo Post Franky, muito bom e didático. Grande abraço