Knowledge Base

How Can We Help?

How to Install MySQL on CentOS 7

You are here:

MySQL is the second most popular Relational database management system available in the market. It is now possessed by Oracle company but it is free and open-source. You can utilize it for any purpose without acquiring the license.

CentOS is also an extremely well-liked server operating system and millions of development/staging/production servers around the globe are powered by CentOS operating system.

In the case of CentOS, You cannot simply execute yum install mysql or any other simple one-liner to set up MySQL on your server as it comes with MariaDB which is a branch of MySQL and then developed in a different manner.

In this concise tutorial, I will demonstrate How to install MySQL on CentOS 7.

Downsides of installing MySQL on CentOS 7

To install MySQL on your CentOS 7 server, First, log in to the server as a root user or a non-root user with sudo privileges. Then, click here to access the Official MySQL downloads page to obtain the link of the MySQL we want to set up on our server.

We don’t need to download it by using the Download button. Alternatively, note down the File name and the MD5 of the file so that we can verify it once it’s downloaded on our server.

Install Mysql On Centos 7

Now, Copy the file name and use it in the wget command as follows to download the MySQL 8 on our CentOS server. You can find the package name under the name of the Download.

# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

You can verify if the file is correct and is not altered via the network using the subsequent command.

# md5sum mysql80-community-release-el7-3.noarch.rpm

The concept is, the MD5 string you get as an output should match with the one displayed on the website. It is to ensure that the package we are going to add to our server is legitimate.

Now, It’s time to add the package we just downloaded to our system. Execute the following command to do so.

# rpm -ivh mysql80-community-release-el7-3.noarch.rpm

Once the package is added to our system, we can install MySQL on our server. Execute the following command to finally install the MySQL server on CentOS 7 Operating System.

# yum install mysql-server

It might take a minute or more to install MySQL depending on the quality of your network and the computing power available on your machine.

After the installation is complete, You can execute the following command to start the MySQL service on your server.

# sudo systemctl start mysqld

Then, check if the MySQL service is actually working or not using the status command as given below.

# sudo systemctl status mysqld

If you see the status of the service active (running), Great! The MySQL is finally working on your CentOS server and you can now use it to manage your databases.

So, this is the procedure to install and initiate the MySQL service on your CentOS server. It’s a reasonably uncomplicated process if you don’t have any additional configuration requirements. If you are encountering any difficulties while installing MySQL on your server, please let us know in the comment section provided below and we will assist you as soon as possible.

Leave a Comment