How to install MySQL 5.6 on CentOS 7

How to install MySQL 5.6 on CentOS 7 post thumbnail image

MySQL is a well-known database server. By default, CentOS 7 and RHEL 7 have MariaDB. However, If you want to use MySQL then you need to remove the MariaDB then install MySQL packages.

In this article will discuss how to install MySQL 5.6 version on CentOS or RHEL 7 Server.

Step 1: Update you repos using yum update commnad.

# yum update -y

Step 2: Remove MariaDB packages by using yum remove.

# yum remove mariadb mariadb-server -y

Step3 : To install MySQL packages, first you have to install MySQL community repositories.

# rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 
# rpm -ivh mysql-community-release-el7-5.noarch.rpm

Step 4: Install MySQL packages now using yum

# yum install -y mysql-server mysql

Step 5: Start mysql service and enable to run service when system reboots.

# systemctl start mysqld
# systemctl enable mysqld

Step 6: You ready to use your MySQL server but wait.. Before using you need to secure your MySQL server. To secure your mysql run this command and provide good password for your MySQL user.

# mysql_secure_installation

Example prompts and outputs:

[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

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? [Y/n]
... 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? [Y/n]
... 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? [Y/n]
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- 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? [Y/n]
... Success!

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up...

That’s it. You can now use your MySQL server by connecting this command.

# mysql -u root -p

Example output:

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.6.50 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql>








Learn how to upgrade PHP on CentOS / RHEL

2 thoughts on “How to install MySQL 5.6 on CentOS 7”

  1. Suresh says:

    Thanks for the easy steps

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Enable SSL on your website in UbuntuEnable SSL on your website in Ubuntu

To enable SSL on your website first you need to install SSL on your server. Install SSL Certificates 1. First edit ssl file in apache2 directory. Add these lines: Change your SSL file location on these lines SSLCertificateFile /etc/letsencrypt/live/linoide.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/linoide.com/privkey.pem 2. Now link default ssl file as shown below