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.

Try Hostinger’s VPS Hosting and get a massive 77% discount!

Get Started

How to Install MySQL on a CentOS 7 Server

There are three steps needed when you want to install MySQL — downloading the MySQL repository, installing it, and checking its status. We’ll go through each step in greater detail.

1. Downloading and Preparing the MySQL Repository

Before we begin, make sure that either your VPS or dedicated 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.

  1. We need to update our system by typing in the following command:
    sudo yum update
  1. After the system is updated, it is time to download the MySQL repositories. You can also view other repository versions here.
    sudo wget
  1. At the end of the download, you should see a confirmation message that .rpm file was saved.
    Downloading MySQL 8 on CentOS 7.
  2. 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-3.noarch.rpm
  1. Once the output indicates that the update and installation are complete, you will be able to install MySQL.

2. Installing MySQL

  1. Use the following command to install MySQL:
sudo yum install mysql-server
  1. The script will return with a list of packages and ask you for confirmation to download and install them. Type y and press ENTER for each of the requests.
    Installing MySQL on CentOS 7.
  2. You’ll need to do this a few times, but you’ll eventually see the Complete! message at the end of the installation — it means that you have successfully installed MySQL on your server.

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
  1. You will get no response once MySQL starts so to check if it is working properly, use the command below:
    sudo systemctl status mysqld
  1. It will output the information about the MySQL process:
    Checking MySQL status.

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


You have learned how to install MySQL on a CentOS 7 server. By installing MySQL, you are able to store your databases and manage them efficiently on your server.

Be sure to check out our other VPS tutorials and leave a comment down below if you have any questions.

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