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 among website/server applications. It allows users to store their databases and manage them using SQL commands on various platforms. In this particular tutorial, we will learn how to install MySQL on a Linux server running CentOS 7 operating system using the command line of your server.

What you’ll need

Before you begin this guide you’ll need the following:

  • root access to your server
  • CentOS 7 running on your Linux server

Step 1 — Downloading and preparing MySQL repository

Before we start, you should connect to your server via SSH and prepare to put commands to your command line.

  1. First of all, we must check if our system is updated and update it if it is not. Type command:
    sudo yum update
  2. Wait for the system to be updated. Now it is necessary to download MySQL repositories. The newest release at the end of the year 2016 is el7-9 so we will use it. (You can check other versions here: https://dev.mysql.com/downloads/repo/yum/). Type in command:
    wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
  3. At the end of the download, you should see that .rpm file was saved.
    downloading mysql repo saved
  4. Now we need to prepare the repository so we could later install MySQL packages from it. Type:
    sudo rpm -Uvh mysql57-community-release-el7-9.noarch.rpm

    You should be able to see a similar response:
    preparing mysql repo finished

Once you reach 100%, you will be able to install MySQL on your server. You will be further instructed how to do it in Step 2.

Step 2 — Installing MySQL on your server

  1. You can go right ahead and install MySQL with the command:
    sudo yum install mysql-server
  2. A list of packages will be provided and you will be asked for confirmation to download them. Type y and press ENTER.
    installing mysql
    While packages are being downloaded you will see the progress:
    downloading mysql packages
  3. When they finish downloading you will again be asked for confirmation to install them. Type y and press ENTER.
    installing mysql packages
  4. Wait for the installation to be completed.
    installing mysql completed

If you see the Complete! message at the end of installation it means that MySQL was installed successfully on your server.

Step 3 — Starting MySQL and checking if it works

  1. MySQL is not started right after the installation so you need to start it with this command:
    sudo systemctl start mysqld
  2. Wait for a few seconds. You will get no response once MySQL starts, but in order to check if it has successfully started and is working use command:
    sudo systemctl status mysqld

    Information about MySQL status will be given:
    status mysql

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


We have learned how to properly install MySQL on your CentOS 7 server so you could store your databases on it and manage them with the help of this great database management system.

About the author

Linas L.

Linas started as a customer success agent and is now a full-stack web 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.


Click here to post a comment

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

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in VPS
How to Install ClamAV on CentOS 7
How to Install ClamAV on CentOS 7