Install MySQL 5.7 On RHEL/CentOS 7/6/5 And Fedora 23/22/21


MySQL is the world’s most popular free and open source database management system and is very popular among developers in application development.  MySQL is one of the very basic examples of Structured Query Language (SQL) used in Relational Database Management Systems.

The following article will guide you to install   MySQL 5.7.9  on  RHEL / CentOS 7/6/5  and  Fedora 23/22/21  using the  MySQL Yum  repository using the YUM command  .

Step 1: Add MySQL Yum Repository

1.  This guide is used to install on Linux operating system without MySQL, if you have installed MySQL from another source, you should upgrade or replace it with a version from MySQL Yum Repository.

Before doing this, don’t forget to back up the database.

2.  Add the  MySQL Yum repository  to the system to install MySQL.

On RHEL / CentOS 7

# wget

On RHEL / CentOS 6

# wget

On RHEL / CentOS 5

# wget

On Fedora 23

# wget

On Fedora 22

 # wget

On Fedora 21

# wget

3.  After downloading, the next command will use yum to install.

On RHEL / CentOS 7

# yum localinstall mysql57-community-release-el7-7.noarch.rpm

On RHEL / CentOS 6

# yum localinstall mysql57-community-release-el6-7.noarch.rpm

On RHEL / CentOS 5

# yum localinstall mysql57-community-release-el5-7.noarch.rpm

On Fedora 23

# dnf localinstall mysql57-community-release-fc23-7.noarch.rpm

On Fedora 22

# dnf localinstall mysql57-community-release-fc22-7.noarch.rpm

On Fedora 21

# yum localinstall mysql57-community-release-fc21-7.noarch.rpm

4.  You can check whether the MySQL Yum repository has been added to your system using the following command.

# yum repolist enabled | grep "mysql. * - community. *"
# dnf repolist enabled | grep "mysql. * - community. *" [On

Fedora 22+

# yum repolist enabled | grep "mysql. * - community. *"
# dnf repolist enabled | grep "mysql. * - community. *" [On Fedora 22+ versions]

Step 2: Install MySQL

5.  Install MySQL with the following command.

# yum install mysql-community-server
# dnf install mysql-community-server [On Fedora 22+ versions]

Step 3: Start MySQL Server

6.  Start MySQL server with the command:

# service mysqld start

Check MySQL server status

# service mysqld status

On Centos 7, use the systemctl command

Redirecting to / bin / systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since Thu 2015-10-29 05:15:19 EDT; 4min 5s ago
Process: 5314 ExecStart = / usr / sbin / mysqld --daemonize $ MYSQLD_OPTS (code = exited, status = 0 / SUCCESS)
Process: 5298 ExecStartPre = / usr / bin / mysqld_pre_systemd (code = exited, status = 0 / SUCCESS)
Main PID: 5317 (mysqld)
CGroup: /system.slice/mysqld.service
└─5317 / usr / sbin / mysqld --daemonize
Oct 29 05:15:19 localhost.localdomain systemd [1]: Started MySQL Server.

7.  Confirm the installed version with the following command:

# mysql --version
 mysql Ver 14.14 Distrib 5.7.9, for Linux (x86_64) using EditLine wrapper

Step 4: Set up security for MySQL

8.  The command  mysql_secure_installation  allows you to set security for MySQL (set password for root account, delete anonymous account, don’t allow root account to log in directly)

Note : After installation, MySQL   5.7   and above automatically generate a random password now  /var/log/mysqld.log

Use the following command to see random passwords:

# grep 'temporary password' /var/log/mysqld.log

After knowing the random password, use the following command to secure the MySQL:

# mysql_secure_installation

Note : After entering a random password, follow the instructions below.

Securing the MySQL server deployment.
Enter password for user root: Enter New Root 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 the VALIDATE PASSWORD plugin?
Press y | Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length> = 8
MEDIUM Length> = 8, numeric, mixed case, and special characters
STRONG Length> = 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.
Estimated strength of the password: 50 
Change the password for root? ((Press y | Y for Yes, any other key for No): y 
New password: Set New MySQL Password 
Re-enter new password: Re-enter New MySQL Password
Estimated strength of the password: 100 
Do you wish to continue with the password provided? (Press y | Y for Yes, any other key for No): y
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
Remove anonymous users? (Press y | Y for Yes, any other key for No): y
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
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
Remove test database and access to it? (Press y | Y for Yes, any other key for No): y
- Dropping test database ...
- Removing privileges on test database ...
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
All done! 

Step 5: Connect to MySQL Server

9.  Access MySQL with the following command:

# mysql -u root -p

Step 6: Update MySQL with the Yum command

10.  In addition to a new installation, you can update MySQL with the following command:

# yum update mysql-server
# dnf update mysql-server [On Fedora 22+ versions]

Above is the instruction to install MySQL 5.9 on Linux operating system.