Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Creating Users and Managing Privileges in MySQL

The ability to create users and manage privileges provides a granular level of security and access in MySQL. In this lab, you will be tasked with creating new users in the MySQL server and deleting users that no longer need access. Once the users are created, you will need to grant the appropriate privileges to each user so that they have access to the correct databases and tables within the server.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 1h 0m
Published
Clock icon May 10, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create the Following Four Users on the MySQL Server: `corey`, `will`, `mike`, and `myles`, and Allow Logins from `localhost` Only, Using the Password `Linux4you!`

    Once logged in to the MySQL server, run the following command to create the users:

    mysql> CREATE USER 'corey'@'localhost' IDENTIFIED BY 'Linux4you!','will'@'localhost' IDENTIFIED BY 'Linux4you!','mike'@'localhost' IDENTIFIED BY 'Linux4you!','myles'@'localhost' IDENTIFIED BY 'Linux4you!';

  2. Challenge

    Delete the User `stosh` from the MySQL Server

    Delete the user stosh using the DROP statement:

    mysql>DROP USER 'stosh'@'localhost';

  3. Challenge

    Grant Privileges on the Newly Created Users According to the Information Provided in the Instructions

    Grant all privileges on the dev database to the corey user:

    mysql> GRANT ALL ON dev.* TO 'corey'@'localhost';

    Grant INSERT and SELECT privileges on the products table in the dev database to will:

    mysql> GRANT SELECT, INSERT ON dev.products TO 'will'@'localhost';

    Grant ALL privileges on the prod database to the mike user:

    mysql> GRANT ALL ON prod.* TO 'mike'@'localhost';

    Grant SELECT privileges on the products table in the prod database to myles user:

    mysql> GRANT SELECT ON prod.products TO 'myles'@'localhost';

  4. Challenge

    Revoke the INSERT Privilege from the `kenny` User on the `orders` Table in the `prod` Database

    Revoke the INSERT privilege from the kenny user running the following command:

    mysql> REVOKE INSERT ON prod.orders FROM 'kenny'@'localhost';

  5. Challenge

    Optionally, Validate the Updated Privileges by Testing User Access

    Ensure that the user corey does not have access to the prod database. Run the following as the corey user:

    mysql> SELECT * FROM prod.orders;

    Ensure that the user will does not have access to the orders table on the dev database. Run the following as the will user:

    mysql> SELECT * FROM dev.orders;

    Ensure that the user mike does not have access to the dev database. Run the following as the mike user:

    mysql> SELECT * FROM dev.orders;

    Ensure that the user myles does not have access to the orders table in the prod database. Run the following as the myles user:

    mysql> SELECT * FROM prod.orders;

    Ensure that the user kenny does not have INSERT privileges on the orders table in the prod database. Run the following as the kenny user:

    mysql> INSERT INTO prod.orders (orderID,userName,orderType,purchaseDate) VALUES (4,'mike','laptop','2018-04-08');

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans