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.
- We need to update our system by typing in the following command:
sudo yum update
- 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.
- 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
- Use the following command to install MySQL:
sudo yum install mysql-server
- 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.
You 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
- MySQL does not automatically start right after the installation. Therefore, you need to start it manually through the following command:
sudo systemctl start mysqld
- 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.
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!