Install and Configure MySQL Server (Ubuntu)

1 hour
  • 5 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 Ubuntu 18.04 and ensuring that it has been properly secured.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Download the Repository
  1. Download the MySQL APT repository configuration file from the MySQL APT repository download page. In the cloud_user‘s home directory, run the following:

    wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
Install the Release Package and Synchronize the Package Index Files

Install the downloaded release package for the MySQL server and re-synchronize the package index files. In the package configuration window, make sure that the MySQL server and cluster is set to mysql-8.0 and the MySQL tools and connectors is Enabled

  1. In the cloud_user’s home directory, use the dpkg package manager to install the release package:

    sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb
  2. In the package configuration window, ensure that the MySQL Server and Cluster is set to mysql-8.0, the MySQL Tools and Connectors is Enabled, and the MySql Preview Packages is Disabled, then hit Ok:

    MySQL Server & Cluster (Currently selected: mysql-8.0)
    MySQL Tools & Connectors (Currently selected: Enabled)
    MySQL Preview Packages (Currently selected: Disabled)
    Ok
  3. Resynchronize the package index:

    sudo apt update
Install MySQL Server and Dependencies
  1. Use the apt command to install the MySQL server:

    sudo apt install -y mysql-server

    Once prompted, enter the following password: Linux4me!, then select Use Strong Password Encryption (RECOMMENDED).

Validate Service Status
  1. Validate that the mysql service is running:

    sudo systemctl status mysql
  2. Log in to the MySQL server as the root user (enter password when prompted):

    mysql -u root -p
  3. To log out of the mysql prompt type exit and hit enter.

Secure the MySQL Server Installation

Secure the MySQL server installation by ensuring that the validation password policy is set to strong, removing anonymous users, disabling remote root login, removing the test database, and reloading the privilege tables.

  1. Begin the installation by running the mysql_secure_installation command (enter the Linux4me! password when prompted):

    mysql_secure_installation
  2. Answer the following questions to complete the secure installation:

    Setup VALIDATE PASSWORD component? y
    Set the level of the password validation password to STRONG: 2 
    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 .deb files from the MySQL server downloads page. Once we have obtained the 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 APT repository configuration file is here: https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
  • 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?