Install MySQL on CentOS 7
Install MySQL on CentOS 7

You can get simple and understandable steps to install MySQL on CentOS. Before we move into the installation, let’s have a brief look on the MySQL.

If you don’t have installed PHP on CentOS 7 you can install one by following These Instructions.

What Is MySQL?

Let me tell you. MySQL open-source tool and Database Management System. MySQL is a fast, stable, true multi-user, multi-threaded SQL database server. Apart from the free edition, MySQL also offers other services like MySQL Enterprise Edition, MySQL Cluster CGE, Oracle MySQL Cloud Service and MySQL for OEM/ISV.

Drupal, Joomla, phpBB, and WordPress are some examples of MySQL database-driven web application. Facebook, Flickr,MediaWiki, Twitter and YouTube are some examples of MySQL databasedriven websites.

What Is CentOS?

The CentOS is a Community Enterprise Operating System. It is an open source platform for non-productive developmental work. For production concern, those works can be migrated to RHEL (Payable) Linux distribution platform.

Let’s have a quick look on MySQL Features and versions available !!!
MySQL is having Embedded database library. It supports Multiple and Native storage engines. MySQL is a component of the LAMP web application software stack and provides high scalability, flexibility and productivity. MySQL is a default version in Maria DB but not in CentOS.

Here’s the Complete Version list of MySQL -> MySQL 3.19, MySQL 3.20, MySQL 3.21, MySQL 3.22, MySQL 3.23, MySQL 4.0, MySQL 4.01, MySQL 4.1, MySQL 5.0, MySQL 5.1, MySQL 5.5, MySQL 5.6, MySQL 5.7, 6.0.11, MySQL 8.0

Install MySQL on CentOS:

Yeah We are ready to start the installation of MySQL on CentOS. Let’s Go.

VM Setup:

First Step is to log-in to your google cloud account and then we need to select option “Compute Engine” in the menu.

Here we gave the two most commonly used version of MySQL will be discussed for your better understanding. Please choose any one version for your server. Also look for the tip to install any version of MySQL.

A) Install MySQL 8.0:

If you choose MySQL 8.0 for installation on CentOS 7. You can follow the below commands for installation.

First, We need to Enable the MySQL 8.0 Repository Package because MySQL 8.0 is not a default package in CentOS 7. Use the below command to enable for local installation.

sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

Now the MySQL 8.0 Repository Package got enabled in the CentOS. We can directly install the package using below mentioned command.

sudo yum install mysql-community-server

One more important thing is to verify the signature Key. For a specific package, you first need to obtain a copy of public GPG build key. While installation it will be asked for key permission. You need to press ‘Y’ And hit “Enter”.

sudo yum install mysql-community-server

With this step MySQL 8.0 package was installed, we can start setting up the MySQL environment.

B) Install MySQL 5.7:

If you choose MySQL 5.7 for installation on CentOS 7 . You can follow the below commands for installation.

First, We need to Enable the MySQL 5.7 Repository Package.

sudo yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

Now the MySQL 5.7 Repository Package got enabled in the CentOS. We can install the package using below mentioned command.

sudo yum install mysql-community-server

One more important thing is to verify the signature Key. For a specific package, you first need to obtain a copy of public GPG build key. While installation it will be asked for key permission. You need to press ‘Y’ And hit “Enter”.

With this step MySQL 5.7 package was installed , we can start setting up the MySQL environment.

C) Install Any Version of MySQL in CentOS:

To install other version of MYSQL, You just need change the .rpm file in the enable command.

sudo yum localinstall https://dev.mysql.com/get/[You version RPM file].rpm

After installation of MySQL:


1) Enabling the MySQL Service:

Hereafterall the steps will be common for any version of MySQL installation which you did.

First , we need to enable “mysqld” which is MySQL server help to run the package in background during the boot time. Use below command for enabling the server.

sudo systemctl enable mysqld

Secondly, after enabling the server we need to start the server for the connectivity by using the below command.

sudo systemctl start mysqld

Then we need to check with the status of the server for its operating status. You can use below command to check the status in the output terminal – Status: “SERVER_OPERATING”

sudo systemctl status mysqld

2) Securing your Credentials:

For the first time when you start with your MySQL server, you will have default password in the MySQL server root user. You can locate the default password by using below command.

sudo grep ‘temporary password’ /var/log/mysqld.log

In the output your default password will be displayed. Remember your default password, will will help you to login in further steps.

To enhance the security of the MySQL installation, use below command.

sudo mysql_secure_installation

When you execute the above command, it will be asked for a password. You need to enter your password here.

After this, you need to enter your own password.
For your secure password: 8 Char length, 1 upper case, 1 lowercase, 1 special character, and 1 Numeric char.
Now the MySQL server will ask you some questions regarding Access, User Permission, remove the database. You should Enter ‘Y’ for all questions.

3) Login Setup to Your MySQL Server:

We all set with our credentials , we are ready to login to the MySQL Server. For that we need to enter into the root of MySQL server. You can enter below command to get into the root.

mysql -u root -p

Once you entered into the root, you will be asked for your own password, which we created in previous steps.

4) Database and Table Creation:

We all set with the MySQL server. To create the database, you can use below command.

Mysql > CREATE DATABASE new_database;

We created our database, now we can get into our database using the following command.

Mysql > use new_database;

Below is the simple structure of table creation.

CREATE TABLE example ( emp_id INT PRIMARY KEY, emp_name VARCHAR(50), emp_email VARCHAR(50) );

Here you go…!! We successfully installed and created our first table in MySQL on CentOS.

Let’s rock by working on MySQL !!

Today, we learned about “What is MySQL ”, “Basics of MySQL and CentOS”, “Versions available in MySQL ”, “Steps to be followed before installing MySQL ”, “How to install MySQL on CentOS?” , “Steps to be followed after installing MySQL ” and finally “How to validated and Creation of database MySQL ”.

Hope it helped you in an easy way to install MySQL with more understanding. Please let us know in the comment section if you have any concern.
You can also share with your friends, who need to install MySQL. Will meet you in my upcoming articles. Bye for now.