How to Install MySQL 8 on CentOS 7.6

Installation of MySQL 8 On centos 7.6

MySQL is a freely available open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL).This Tutorial covers the installation of Mysql 8 On Centos 7.6

Installation

Check the centos version by using the following command

[root@linuxhelp ~]# rpm -q centos-release
centos-release-7-6.1810.2.el7.centos.x86_64
Now download and add the following MySQL Yum repository  
 [root@linuxhelp ~]# wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
--2019-06-05 20:08:23--  https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.75.165.42
Connecting to repo.mysql.com (repo.mysql.com)|104.75.165.42|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25820 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-1.noarch.rpm’

100%[==========================================================>] 25,820      --.-K/s   in 0.06s   

2019-06-05 20:08:23 (408 KB/s) - ‘mysql80-community-release-el7-1.noarch.rpm’ saved [25820/25820]

Now install the downloaded package with the following command.

 [root@linuxhelp ~]# yum install -y mysql80-community-release-el7-1.noarch.rpm
Loaded plugins: fastestmirror, langpacks
Examining mysql80-community-release-el7-1.noarch.rpm: mysql80-community-release-el7-1.noarch
Marking mysql80-community-release-el7-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-1 will be installed
--> Finished Dependency Resolution
base/7/x86_64                                                                | 3.6 kB  00:00:00     
extras/7/x86_64                                                              | 3.4 kB  00:00:00     
extras/7/x86_64/primary_db                                                   | 200 kB  00:00:00     

Dependencies Resolved

====================================================================================================
 Package                      Arch      Version    Repository                                  Size
====================================================================================================
Installing:
 mysql80-community-release    noarch    el7-1      /mysql80-community-release-el7-1.noarch     31 k

Transaction Summary
====================================================================================================
Install  1 Package

Total size: 31 k
Installed size: 31 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql80-community-release-el7-1.noarch                                           1/1 
  Verifying  : mysql80-community-release-el7-1.noarch                                           1/1 

Installed:
  mysql80-community-release.noarch 0:el7-1                                                          

Complete!

Verify that the MySQL Yum repository has been added successfully by using following command.

[root@linuxhelp ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64       MySQL Connectors Community           108
mysql-tools-community/x86_64            MySQL Tools Community                 90
mysql80-community/x86_64                MySQL 8.0 Community Server           113
Install the mysql  using the following command.
[root@linuxhelp ~]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.dhakacom.com
* extras: mirrors.viethosting.com
* updates: mirror.dhakacom.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.16-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.16-2.el7 for package: mysql-community-server-8.0.16-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.16-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.16-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.16-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.16-2.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
.
.
.
.
Installed:
 mysql-community-libs.x86_64 0:8.0.16-2.el7     mysql-community-libs-compat.x86_64 0:8.0.16-2.el7  
 mysql-community-server.x86_64 0:8.0.16-2.el7  

Dependency Installed:
 mysql-community-client.x86_64 0:8.0.16-2.el7     mysql-community-common.x86_64 0:8.0.16-2.el7    

Replaced:
 mariadb-libs.x86_64 1:5.5.60-1.el7_5                                                              

Complete!

Start the mysql service by using the following command

 [root@linuxhelp ~]# systemctl start mysqld

Enable the mysql service by using the following command

 [root@linuxhelp ~]# systemctl enable mysqld

Check the mysql version by using the following command

 [root@linuxhelp ~]# mysql -V
mysql  Ver 8.0.16 for Linux on x86_64 (MySQL Community Server - GPL)

Check the temporary password for mysql by using this method

 [root@linuxhelp ~]# grep 'temporary password' /var/log/mysqld.log
2019-06-05T14:58:43.375678Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: .e<=drCjE7#6

Now secure the myslq root password by using the following command

[root@linuxhelp ~]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: 

Re-enter new 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! 

Enter into the MySQL by using the required credentials

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

Copyright (c) 2000, 2019, 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> exit
Bye

With this the method of installation of Mysql 8 on Centos 7.6

Tag : MySQL CentOS
FAQ
Q
How to secure the MySQL root user?
A
By using the following command you can secure the root user for MySQL



#mysql_secure_installation
Q
How to check the temporary password for mysql ?
A
Use the following command to check the temporary password

grep 'temporary password' /var/log/mysqld.log
Q
What is the use of mysql?
A
MySQL is a freely available open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL)
Q
How to check the version for mysql?
A
Type the follwoing command

mysql -V

to check the version of mysql
Q
What are the alternatives for mysql?
A
These are the alternatives for mysql

Mariadb
Postgresql
CouchDB