MySQL is the second most popular Relational database management system available in the market. It is now owned by Oracle company but it is free and open-source. You can use it for any purpose without obtaining the license.
CentOS is also a very popular server operating system and millions of development/staging/production servers around the world are powered by CentOS operating system.
In the case of CentOS, You cannot simply run yum install mysql
or any other simple one-liner to install MySQL on your server as it comes with MariaDB which is a fork of MySQL and then developed in a different way.
In this short tutorial, I am going to show you How to install MySQL on CentOS 7.
Install 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 open the Official MySQL downloads page to get the link of the MySQL we want to install on our server.
We do not have to download it by using the Download button. Instead, the note down the File name and the MD5 of the file so that we can verify it once it’s downloaded on our server.
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 following command.
# md5sum mysql80-community-release-el7-3.noarch.rpm
The idea 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 legit.
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 how you can install and start the MySQL service on your CentOS server. It’s a fairly easy process if you don’t have any additional configuration requirements. If you are facing any issues while installing MySQL on your server, please let us know in the comment section given below and we will get back to you with help as soon as possible.