MariaDB is now implemented as a default database in CentOS 7/ RHEL 7. Many organizations / company still want MySQL to continue. Whereas Syetm Admin who worked on MySQL earlier will work easily on MariaDB. MariaDB is a fork of MySQL relational database management system developed by the Community.

In this we are going to setup Mysql 5.6 in Centos 7. For start this installation process you have required sudo privilege or root user access.

Installation:-

1. You have to downlaod the rpm package for create yum repo file for MySql Server installation.

[[email protected] ~]# yum install wget
[[email protected] ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2. Now you need to install the downloaded rpm package by using below command:

[[email protected] ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

3. When the installation will be completed. You will get two new yum repo related to MySQL.

[[email protected] ~]# ls -1 /etc/yum.repos.d/mysql-community*
/etc/yum.repos.d/mysql-community.repo
/etc/yum.repos.d/mysql-community-source.repo

4. Now we are going to install MySql server using below command.

[[email protected] ~]# yum install mysql-server -y

Start,stop and status of MySql

1. You can start the MySql service using command below.

[[email protected] ~]# systemctl start mysqld

2. You can stop the MySql service using command below.

[[email protected] ~]# systemctl stop mysqld

3. You can restart the MySql service using command below.

[[email protected] ~]# systemctl restart mysqld

4. You can check the status of MySql service using command below.

[[email protected] ~]# systemctl status mysqld

To Set MySQL root password(Securing the MySQL Installation)

1. Run the below command to get the temporary password of MySql after installation of MySql.

[[email protected] ~]# grep 'temporary password' /var/log/mysqld.log

2. As now you get the temp password and run the command below to secure MySql.

[[email protected] ~]# mysql_secure_installation

3. After run this mysql_secure_installation you will get the output like below so please use step which are available in output.

Securing the MySQL server deployment.
Enter password for user root: Enter New Root Password
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.
Estimated strength of the password: 50
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: Set New MySQL Password
Re-enter new password: Re-enter New MySQL Password
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Dropping test database…
Success.
Removing privileges on test database…
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!

4. Try to login with new password using below command.

[[email protected] ~]# mysql -u root -p
Enter password:
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

Now MySql server is installed and ready to use.

Thankyou……