How to install MySQL 8 on CentOS 8

How To Install MySQL 8 on Centos 8

On this article we will discuss how to install MySQL 8 on CentOS 8. There are two packages source of MySQL database : Developer Community Edition and AppStream. On this article we will show you how to install MySQL using repository from Developer Community Edition.

Introduction

MySQL is free and open-source database software under the terms of the GNU General Public License, and is also available under a variety of proprietary licenses. MySQL formerly was owned and sponsored by the Swedish company MySQL AB, which was bought by Sun Microsystems (now Oracle Corporation). In 2010, when Oracle acquired Sun, Widenius forked the open-source MySQL project to create MariaDB.

The latest stable version of the MySQL database server, is version 8.0.21 which was released on July 13, 2020. The package is available for installation from the default CentOS 8 repositories. The installation process will be consist of several steps, namely:

  1. Prerequisites
  2. Installing MySQL (From Developer Community Edition)
  3. Managing MySQL Services
  4. Securing MySQL
  5. Login to MySQL

Prerequisites

Before we are going to install MySQL 8 on the system, there are several prerequisites to be fulfilled, namely :

  • A system running CentOS 8
  • Sufficient disk space and good internet access for downloading the package source
  • Sudo or root privileges

Installing MySQL 8.0 on CentOS 8

There are two packages source of MySQL database, namely : Developer Community Edition and AppStream. We will try to install MySQL database using these two options, as our tutorial.

On this package option we will get the latest or a specific version of MySQL. Sometimes, software developers release newer versions faster than they are uploaded to the default Linux repositories. In this step, we bypass the default repository and install straight from the developer’s repository. detailed steps as follows.

  1. Enabling MySQL developer repository.
[root@otodiginet ~]# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm

the output :

Retrieving https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
warning: /var/tmp/rpm-tmp.SeyHUg: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying… ################################# [100%]
Preparing… ################################# [100%]
Updating / installing…
1:mysql80-community-release-el8-1 ################################# [100%]
enable and download MySQL from Developer Community Edtion

2. Verify the repository, by submitting command line below.

[root@otodiginet ~]# dnf repolist all | grep mysql | grep enabled
verify the repository

3. Disable the AppStream and Install MySQL 8.0 Community Server, by submitting command.

[root@otodiginet ~]# dnf --disablerepo=AppStream install mysql-community-server -y
Disable Appstream repository and install MySQL

After installation was completed done successfully, then we verify the installation by querying the MySQL version. This step will be done by submitting command belo.

[root@otodiginet ~]# mysql -Version
mysql Ver 8.0.21 for Linux on x86_64 (MySQL Community Server - GPL)
MySQL version

Managing MySQL Services

So far, the MySQL 8.0 installation was completed done, then we will manage the MySQL services by starting, enabling and querying the status of MySQL services.

[root@otodiginet ~]# systemctl start mysqld
[root@otodiginet ~]# systemctl enable mysqld
[root@otodiginet ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-07-29 07:24:42 PDT; 29s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 5061 (mysqld)
Status: "Server is operational"
Tasks: 39 (limit: 23810)
Memory: 435.2M
CGroup: /system.slice/mysqld.service
└─5061 /usr/sbin/mysqld
Enable and starting MySQL service

Securing MySQL

Before we use the fresh MySQL on our system, it is recommended for us to secure MySQL database to enable security features. Because, by default MySQL installation lacks many common security features. We have to run the secure installation script to enable security features. These features include disabling remote login, removing anonymous user support,and defining a new MySQL root password.

Before we use the fresh MySQL on our system, it is recommended for us to secure MySQL database to enable security features. Because, by default MySQL installation lacks many common security features. We have to run the secure installation script to enable security features. These features include disabling remote login, removing anonymous user support,and defining a new MySQL root password.

There are several steps to Securing MySQL, as described below :

  1. Querying MySQL root password
    First use, MySQL requires root password to login to the database. For this purpose we have to get the temporary (default) root password, the command for doing this :
[root@otodiginet ~]# cat /var/log/mysqld.log | grep -i 'temporary password'
2020-07-29T14:24:35.743714Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wyY#%telw7ji
MySQL temporarty root password
  1. Run mysql_secure_installation script and follow the instruction on it.
    The script is executed by using root or sudo privilege account :
[root@otodiginet ~]# mysql_secure_installation
Output :
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) : n
… skipping.
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.
mysql_secure_installation script

Login to MySQL

After all steps are passed, we can log in to MySQL by submitting command line :

[root@otodiginet ~]# 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.21 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> create database otodiginet;
Query OK, 1 row affected (0.01 sec)

On this example we created one database called as otodiginet and show all listed database.

mysql> create database otodiginet;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| otodiginet |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.07 sec)
login to MySQL and lists all databases.

Conclusion

So far, the MySQL installation on Centos 8 tutorial has been completed done. On this article we are using MySQL Developer community edition repository, version 8.0.21 which was released on which was released on July 13, 2020.

Share this article via :

One thought on “How To Install MySQL 8 on Centos 8

Leave a Reply

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