mysql_install_redhat

Last updated on September 29th, 2022 at 10:02 am

In this post we will be taking a look at installing MySQL on RHEL , Red Hat Linux 8, You need to enable AppStream from RHUI repo to install MySQL. More information on how to proceed step by step is shown below

My server details

  • Red Hat Enterprise Linux release 8.4
  • MySQL version 8.0.26

Steps To Install

Enable Appstream Repo and Install MySQL

Start MySQL service

Run mysql_secure_installation

Connect to MySQL service using new password

Step 1] List the repos enabled

> yum repolist enabled
repo id                                 repo name
mysql-connectors-community              MySQL Connectors Community
mysql-tools-community                   MySQL Tools Community
mysql80-community                       MySQL 8.0 Community Server
rhel-8-appstream-rhui-rpms              Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs)
rhel-8-baseos-rhui-rpms                 Red Hat Enterprise Linux 8 for x86_64 - BaseOS from RHUI (RPMs)
rhui-client-config-server-8             Red Hat Update Infrastructure 3 Client Configuration Server 8

if rhel-8-appstream-rhui-rpms is not enabled please run

> yum-config-manager --enable rhel-8-appstream-rhui-rpms

Step 2] Make sure AppStream repo is enabled, Then install MySQL using yum (output truncated)

> yum install @mysql

Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs)                      43 kB/s | 4.5 kB     00:00
Red Hat Enterprise Linux 8 for x86_64 - BaseOS from RHUI (RPMs)                         41 kB/s | 4.1 kB     00:00
Dependencies resolved.
=======================================================================================================================
 Package                        Arch     Version                                    Repository                    Size
=======================================================================================================================
Installing group/module packages:
 mysql-server                   x86_64   8.0.26-1.module+el8.4.0+12359+b8928c02     rhel-8-appstream-rhui-rpms    25 M
Installing dependencies:
 libaio                         x86_64   0.3.112-1.el8                              rhel-8-baseos-rhui-rpms       33 k
 mariadb-connector-c-config     noarch   3.1.11-2.el8_3                             rhel-8-appstream-rhui-rpms    15 k
 mecab                          x86_64   0.996-1.module+el8+2459+7cb96738.9         rhel-8-appstream-rhui-rpms   398 k
 mysql                          x86_64   8.0.26-1.module+el8.4.0+12359+b8928c02     rhel-8-appstream-rhui-rpms    12 M
 mysql-common                   x86_64   8.0.26-1.module+el8.4.0+12359+b8928c02     rhel-8-appstream-rhui-rpms   134 k
 mysql-errmsg                   x86_64   8.0.26-1.module+el8.4.0+12359+b8928c02     rhel-8-appstream-rhui-rpms   598 k
 perl-Carp                      noarch   1.42-396.el8                               rhel-8-baseos-rhui-rpms       30 k
 perl-Data-Dumper               x86_64   2.167-399.el8                              rhel-8-baseos-rhui-rpms       58 k
 perl-Digest                    noarch   1.17-395.el8                               rhel-8-appstream-rhui-rpms    27 k
 perl-Digest-MD5                x86_64   2.55-396.el8                               rhel-8-appstream-rhui-rpms    37 k
 perl-Encode                    x86_64   4:2.97-3.el8                               rhel-8-baseos-rhui-rpms      1.5 M
 perl-Errno                     x86_64   1.28-420.el8                               rhel-8-baseos-rhui-rpms       76 k
 perl-Exporter                  noarch   5.72-396.el8                               rhel-8-baseos-rhui-rpms       34 k
 perl-File-Path                 noarch   2.15-2.el8                                 rhel-8-baseos-rhui-rpms       38 k
 perl-File-Temp                 noarch   0.230.600-1.el8                            rhel-8-baseos-rhui-rpms       63 k
 perl-Getopt-Long               noarch   1:2.50-4.el8                               rhel-8-baseos-rhui-rpms       63 k
 perl-HTTP-Tiny                 noarch   0.074-1.el8                                rhel-8-baseos-rhui-rpms       58 k
 perl-IO                        x86_64   1.38-420.el8                               rhel-8-baseos-rhui-rpms      142 k
 perl-MIME-Base64               x86_64   3.15-396.el8                               rhel-8-baseos-rhui-rpms       31 k
 perl-Net-SSLeay                x86_64   1.88-1.module+el8.3.0+6446+594cad75        rhel-8-appstream-rhui-rpms   379 k
 perl-PathTools                 x86_64   3.74-1.el8                                 rhel-8-baseos-rhui-rpms       90 k
 perl-Pod-Escapes               noarch   1:1.07-395.el8                             rhel-8-baseos-rhui-rpms       20 k
 perl-Pod-Perldoc               noarch   3.28-396.el8                               rhel-8-baseos-rhui-rpms       88 k
 perl-Pod-Simple                noarch   1:3.35-395.el8                             rhel-8-baseos-rhui-rpms      213 k
 perl-Pod-Usage                 noarch   4:1.69-395.el8                             rhel-8-baseos-rhui-rpms       34 k
 perl-Scalar-List-Utils         x86_64   3:1.49-2.el8                               rhel-8-baseos-rhui-rpms       68 k
 perl-Socket                    x86_64   4:2.027-3.el8                              rhel-8-baseos-rhui-rpms       59 k
 perl-Storable                  x86_64   1:3.11-3.el8                               rhel-8-baseos-rhui-rpms       98 k
 perl-Term-ANSIColor            noarch   4.06-396.el8                               rhel-8-baseos-rhui-rpms       46 k
 perl-Term-Cap                  noarch   1.17-395.el8                               rhel-8-baseos-rhui-rpms       23 k
 perl-Text-ParseWords           noarch   3.30-395.el8                               rhel-8-baseos-rhui-rpms       18 k
 perl-Text-Tabs+Wrap            noarch   2013.0523-395.el8                          rhel-8-baseos-rhui-rpms       24 k
 perl-Time-Local                noarch   1:1.280-1.el8                              rhel-8-baseos-rhui-rpms       34 k
 perl-URI                       noarch   1.73-3.el8                                 rhel-8-appstream-rhui-rpms   116 k
 perl-Unicode-Normalize         x86_64   1.25-396.el8                               rhel-8-baseos-rhui-rpms       82 k
 perl-constant                  noarch   1.33-396.el8                               rhel-8-baseos-rhui-rpms       25 k
 perl-interpreter               x86_64   4:5.26.3-420.el8                           rhel-8-baseos-rhui-rpms      6.3 M
 perl-libnet                    noarch   3.11-3.el8                                 rhel-8-appstream-rhui-rpms   121 k
 perl-libs                      x86_64   4:5.26.3-420.el8                           rhel-8-baseos-rhui-rpms      1.6 M
 perl-macros                    x86_64   4:5.26.3-420.el8                           rhel-8-baseos-rhui-rpms       72 k
 perl-parent                    noarch   1:0.237-1.el8                              rhel-8-baseos-rhui-rpms       20 k
 perl-podlators                 noarch   4.11-1.el8                                 rhel-8-baseos-rhui-rpms      118 k
 perl-threads                   x86_64   1:2.21-2.el8                               rhel-8-baseos-rhui-rpms       61 k
 perl-threads-shared            x86_64   1.58-2.el8                                 rhel-8-baseos-rhui-rpms       48 k
 policycoreutils-python-utils   noarch   2.9-14.el8                                 rhel-8-baseos-rhui-rpms      252 k
 protobuf-lite                  x86_64   3.5.0-13.el8                               rhel-8-appstream-rhui-rpms   149 k
Installing weak dependencies:
 perl-IO-Socket-IP              noarch   0.39-5.el8                                 rhel-8-appstream-rhui-rpms    47 k
 perl-IO-Socket-SSL             noarch   2.066-4.module+el8.3.0+6446+594cad75       rhel-8-appstream-rhui-rpms   298 k
 perl-Mozilla-CA                noarch   20160104-7.module+el8.3.0+6498+9eecfe51    rhel-8-appstream-rhui-rpms    15 k
Installing module profiles:
 mysql/server
Enabling module streams:
 perl                                    5.26
 perl-IO-Socket-SSL                      2.066
 perl-libwww-perl                        6.34

Step 3 ] Start MySQL service and connect to make sure it works

> systemctl start mysqld
mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>

Step 4] Secure the installation using mysql_secure_installation , This step depends on how you want to secure your MySQL instance. Please proceed according to your requirement. Given below is just a sample of how it looks.

> mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT 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 component?

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: 0
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 50
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) : n

 ... skipping.
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!
# 

Step 5] Connect using the new password set for root user. (output truncated). I initially gave wrong password for root user and it declines saying access denied which is what we are looking for.

> mysql -u root -p
Enter Password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
> mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.26 Source distribution

Leave a Reply

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