Home / Tutorials / How to Install MySQL in RHEL/CentOS/Fedora/Ubuntu
Mysql Installation

How to Install MySQL in RHEL/CentOS/Fedora/Ubuntu

MySQL is an open source free relational database management system (RDBMS) released under GNU (General Public License). It is used to run multiple databases on any single server by providing multi-user access to each created database.

Here we are going to walk through you the process of installing and updating latest MySQL on RHEL/CentOS  and Fedora using MySQL Yum repository via YUM utility and on Ubuntu using apt-get.

Step 1: Adding the MySQL Yum Repository

Important: These instructions only works on fresh installation of MySQL on the server, if there is already a MySQL installed using a third-party-distributed RPM package, then I recommend you to upgrade or replace the installed MySQL package using the MySQL Yum Repository or apt-get.

Before Upgrading or Replacing old MySQL package, don’t forget to take all important databases backup and configuration files.

Now download and add the following MySQL Yum repository & Apt repository to your respective Linux distribution system’s repository list

After downloading the package for your Linux platform, now install the downloaded package with the following command.

The above installation command adds the MySQL Yum & Apt repository to system’s repository list and downloads the GnuPG key to verify the integrity of the packages.

You can verify that the MySQL Yum repository has been added successfully by using following command.

In Ubutnu: you will prompt that asks you which MySQL product you want to configure. The MySQL Server option, which is highlighted, should say mysql-5.7. If it doesn’t, press ENTER, then scroll down to mysql-5.7 using the arrow keys, and press ENTER again.

Once the option says mysql-5.7, scroll down on the main menu to Apply and press ENTER again. Now, update your package index.

Step 2: Installing Latest MySQL Version

Step 3: Starting the MySQL Server

After successful installation of MySQL, it’s time to start the MySQL server with the following command:

You can verify the status of the MySQL server with the help of following command.

Now finally verify the installed MySQL version using following command.

Step 4: Securing the MySQL Installation

The command mysql_secure_installation allows you to secure your MySQL installation by performing important settings like setting the root password, removing anonymous users, removing root login, and so on.

Note: MySQL version 5.7 or higher generates a temporary random password in /var/log/mysqld.log after installation.

Use below command to see the password before running mysql secure command.

Once you know the password you can now run following command to secure your MySQL installation.

Note: Enter new Root password means your temporary password from file /var/log/mysqld.log.

Step 5: Connecting to MySQL Server

This will prompt you to enter password. You can directly specify password like below

About cmadmin

Web Developer & Designer | Android App Developer

Check Also

Mysql Backup Restore

MySQL Backup and Restore Commands for Database Administration

Here I’m going to you several practical examples on how to perform various backup operations …

MySql Administration

20 MySQL Administration Commands – mysqladmin

mysqladmin is a command-line utility that comes with MySQL server and it is used by …


Create an Account!
Forgot Password? (close)

Sign Up

Confirm Password
Want to Login? (close)

Forget Password?

Username or Email
To get latest new / tutorial / technology / development information subscribe with us.
Lets Get Updated with latest trends & tutorials!
Your Information will never be shared with any third party.
Ready for latest tutorials & tools !