Install and Configure MySQL Server (CentOS)

1 hour
  • 6 Learning Objectives

About this Hands-on Lab

MySQL server is one of the most popular and widely-used relational databases. In this Lab, you will be tasked with installing a MySQL server on CentOS 7, and ensuring that it has been properly secured.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Download the MySQL RPM Bundle tar File from the MySQL Community Server Downloads Page

In the cloud_user home directory run the following:

# wget

Extract the RPM Files from the MySQL Bundle tar File

In cloud_user’s home directory, Use the tar command to extract the RPM files from the bundle tar file:

[cloud_user@host]$ tar -xvf mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar
Install the MySQL Server and Dependencies Using the `rpm` Command

In cloud_user’s home directory, use the rpm command to install the MySQL server and dependencies:

[cloud_user@host]$ sudo rpm -Uvh mysql-community-{server,client,common,libs}-*
Start up the MySQL Server

Use systemctl to start up the mysqld service:

[cloud_user@host]$ sudo systemctl start mysqld
Update the Password for the Superuser Account on the MySQL Server

Locate the temporary password for the superuser:

[cloud_user@host]$ sudo grep 'temporary password' /var/log/mysqld.log

Using the temporary password, log into the MySQL server as the root user:

[cloud_user@host]$ # mysql -u root -p

Update the password for the root user:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '<NEW_PASSWORD>';

For grading purposes, make sure NEW_PASSWORD is Linux4me!.

Exit the mysql prompt:

mysql> exit
Secure the MySQL Server Installation by Ensuring That Anonymous Users Are Removed, Remote `root` Login Is disabled, the `test` Database Has Been Removed, and the Privilege Tables Have Been Reloaded

Begin the installation by running the mysql_secure_installation command:

cloud_user@host]$ mysql_secure_installation

Answer the following questions to complete the secure installation:

Change the password for root ? n
Remove anonymous users? y
Disallow root login remotely? y
Remove test database and access to it? y
Reload privilege tables now? y

Additional Resources

As database administrators for our company, we have been tasked with performing the initial installation of a MySQL server. In order to perform this task, we will need to download the appropriate RPM files from the MySQL server downloads page. Once we have obtained the RPM files, we will need to install the MySQL server, update the password for the super user, and ensure that the server has been properly secured. To secure the MySQL server, we will need to make sure that anonymous users are removed, remote root login is disabled, the test database has been removed, and that the privilege tables have been reloaded.

Additional Information:

  • All steps should be performed as cloud_user, using sudo when necessary. For convenience, a password is not required when using sudo
  • Our working directory should be /home/cloud_user.
  • The URL for the MySQL RPM Bundle tar file is here:
  • For grading purposes, we will need to update the password for the root user to Linux4me!.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?