April 18, 2024

How to Install MySQL 5.7 on CentOS/RHEL 7/6, Fedora 27/26/25

In this article, we will learn how we can install MySQL 5.7 version on our CentOS/RHEL 7/6, Fedora 27/26/25 system. So let’s get started with the steps as follows:

Step #1 – Enable MySQL Repository

In order to install anything on Linux machine first thing, you will have to do is enable their repository. So in this step, we enable the MySQL 5.7 community release yum repository on your system. The rpm package is also available on MySQL official website. So, therefore, use one of the below commands as per your operating system version.

-- On CentOS and RHEL 7 -- 
# yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

-- On CentOS and RHEL 6 -- 
# yum localinstall https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm

-- On Fedora 27 -- 
# dnf install https://dev.mysql.com/get/mysql57-community-release-fc27-9.noarch.rpm

-- On Fedora 26 -- 
# dnf install https://dev.mysql.com/get/mysql57-community-release-fc26-9.noarch.rpm

-- On Fedora 25 -- 
# dnf install https://dev.mysql.com/get/mysql57-community-release-fc25-9.noarch.rpm

Step #2 – Installing MySQL 5.7 Server

As we have successfully enabled the repository on our system. Now its time to install the MySQL 5.7 Community server on our system using the following commands:-

On CentOS and RHEL 7/6

# yum install mysql-community-server

On Fedora 27/26/25:

#  dnf install mysql-community-server 

The above command will install the MySQL 5.7 Community Server on your system. During this installation process, a temporary password will be created, you can find this password on MySQL log files or follow the steps to find a temporary password.

Step #3 – Start MySQL 5.7 Server

service mysqld start

Then, run the following command to find to get the temporary root password

# grep 'A temporary password' /var/log/mysqld.log |tail -1
Sample Output

2019-04-24T02:57:10.981502Z 1 [Note] A temporary password is generated for root@localhost: Mm(!qKkkjo79y

Step #4 – Initiate MySQL 5.7 Server Configuration

Initiate the mysql_secure_installation script inorder to configure mysql 5.7 server. It will prompt you for the root password , use the temporary root password got in above step.

# /usr/bin/mysql_secure_installation

This configuration wizard will prompt for your inputs and also ask you for the new MySQL password, so, therefore, input a strong password for your MySQL root user.

Sample Output

Securing the MySQL server deployment.

Enter password for user root: **********

The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: ******************

Re-enter new 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
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) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

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!

Step #5 – Login into MySQL 5.7 Server

Congratulations you have successfully installed MySQL 5.7 on your system. Now Login into MySQL with your new password and check whether it’s working or not.

# mysql -h localhost -u root -p  // login command
Sample Information

/* Show Databases*/
mysql> show databases;

/* CREATE NEW DATABASE */
mysql> CREATE DATABASE vedant;

Now you have successfully installed MySQL on your system. In order to check the MySQL version use the following command:-

# mysql -V 

!!!!ENJOY!!!!

Vedant Kumar

Currently I'm working as an Implementation Engineer, Started my career as an System Administrator - Linux. Additionally loves to explore new technologies and research about new open-source software that ease the development cycle.

View all posts by Vedant Kumar →

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

close

Ad Blocker Detected!

VEDANT EXPLAINS
We've noticed that you are using an ad blocker. Advertising helps fund our server cost and keep it truly independent. It helps to build our content creator team. So please disable your ad blocker, and help us to keep providing you with free- great content - for free. Thank you for your support.

Refresh