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.
Table of Contents
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.
- First of all, we must check if our system is updated and update it if it is not. Type command:
sudo yum update
- 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-9so we will use it. (You can check other versions here: https://dev.mysql.com/downloads/repo/yum/). Type in command:
- 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. Type:
sudo rpm -Uvh mysql57-community-release-el7-9.noarch.rpm
You should be able to see a similar response:
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
- You can go right ahead and install MySQL with the command:
sudo yum install mysql-server
- A list of packages will be provided and you will be asked for confirmation to download them. Type
yand press ENTER.
While packages are being downloaded you will see the progress:
- When they finish downloading you will again be asked for confirmation to install them. Type
yand press ENTER.
- Wait for the installation to be 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
- MySQL is not started right after the installation so you need to start it with this command:
sudo systemctl start mysqld
- 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:
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.