How to Install MySQL on CentOS 7

How to Install MySQL on CentOS 7

MySQL is one of the most widely used database management systems for websites and server applications. It’s an essential tool that every webmaster should learn. That’s why in this tutorial, we will show you how to install MySQL on CentOS 7  through an SSH connection.

How to Install MySQL on a CentOS 7 Server

There are three big steps in this article — downloading the MySQL repository, installing MySQL, and starting it. You will see detailed instructions for each step.

Also, before we begin this guide, make sure that your VPS or server is running on CentOS 7 and you have root access to it. You can learn how to connect to your server via SSH by following our tutorial.

Step 1: Downloading and Preparing the MySQL Repository

First, you should connect to your server via SSH. If you are a Hostinger user, you can find the login details in the Servers tab of the hPanel.

  1. We need to update our system by typing in the following command:
    sudo yum update
  2. After the system is updated, it is time to download the MySQL repositories:
    sudo wget

    At the end of the download, you should see that .rpm file was saved.
    The download status of MySQL repository on CentOS 7

  3. Now, we need to prepare the repository so we could later install MySQL packages from it. Simply enter:
    sudo rpm -Uvh mysql80-community-release-el7-1.noarch.rpm

    Once the output indicates that the update and installation are at 100%, you will be able to install MySQL on CentOS 7.

Step 2: Installing MySQL on Your Server

  1. Use the following command to install MySQL:
    sudo yum install mysql-server
  2. The script will return with a list of packages and ask you for confirmation to download and install them. Type in y and press ENTER for each of the requests.
    Installing MySQL on CentOS 7You will see the progress the packages are being downloaded. If you see the Complete! message at the end of the installation, it means that you have successfully installed MySQL on your server.

Step 3: Starting MySQL and Checking its Status

  1. MySQL does not automatically start right after the installation. Therefore, you need to start it manually through the following command:
    sudo systemctl start mysqld
  2. You will get no response once MySQL starts so to check if it is working properly, use the command below:
    sudo systemctl status mysqld

    It will output the information about the MySQL process.
    How to check if MySQL is active

If you see that MySQL is active and running like in the screenshot above, you have successfully installed and started MySQL on your server. Good job!


Now you have learned how to install MySQL on a CentOS 7 server through an SSH connection. You can easily download, install and start the service with the provided commands.

By installing MySQL, you are able to store your databases and manage them efficiently on your server.

Good luck and be sure to check out our other VPS tutorials!

The Author


Linas L. / @linas

Linas started as a customer success agent and is now a full-stack PHP developer at Hostinger. He is passionate about making a positive impact on people by utilizing user-driven development techniques. As much as he enjoys coding and changing the world, he secretly dreams of becoming a rock star.

Related tutorials


Neeraj Jadhav Reply

April 18 2017

I have a Ubuntu 14.04 server. Can I follow these same steps to install MySQL there?


Neeraj Jadhav Reply

April 18 2017

I have a VPS account with Ubuntu 14.04 installed. Do we install mysql on it the same way shown above?


Fawad Reply

March 26 2018

Thank you very much. Very simple, nice and clean tutorial. Worked for me.

Leave a reply




This site uses Akismet to reduce spam. Learn how your comment data is processed.

Become a part of Hostinger now!

More in VPS
How to Install ClamAV on CentOS 7
How to Install ClamAV on CentOS 7: A Step-by-Step Guide