VPS

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 f0r 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 Server 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 https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

    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 isntallation 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!

Conclusion

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!

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.

3 Comments

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: A Step-by-Step Guide

Close