Lab 2: Creating User and Views in MySQL

ModestTheory3085 avatar
ModestTheory3085
·
·
Download

Start Quiz

Study Flashcards

16 Questions

What is the purpose of the GRANT keyword in MySQL?

To grant privileges to a user

What does the REVOKE keyword do in MySQL?

Revokes permissions from a user

What is a View in MySQL?

A logical representation of data in a database

What is the benefit of using Views in MySQL?

It simplifies complex queries

What is a Trigger in MySQL?

A set of SQL statements that is invoked automatically when a change is made to the data

What does the syntax GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON *.* TO 'ahmed'@'localhost'; do?

Grants all privileges to user 'ahmed'

What is the benefit of using Views in terms of data?

It avoids data redundancy

What is the purpose of renaming columns in a View?

To make the query more readable

What is the primary purpose of creating a new user in MySQL?

To provide an additional layer of security

What is the term for the operation a user can perform on a database?

Permission

What is stored in the 'USER' table of the MySQL server?

Login information and account privileges

What is the default status of the ROOT user's password after a MySQL Server installation?

It is not set

What does the 'IDENTIFIED BY' keyword do in the CREATE USER syntax?

Specifies the password

What is the significance of the '@localhost' part in the CREATE USER syntax?

It specifies the host name

Why is it recommended to create a new user in MySQL?

To limit the privileges of the ROOT user

What information does the 'USER' table contain about a MySQL account?

Login information, account privileges, and host information

Study Notes

MySQL User

  • A MySQL user is a record in the 'USER' table of the MySQL server, containing login information, privileges, and host information for a MySQL account.
  • By default, the ROOT user account has all privileges, but it's recommended to create a new user to give specific privileges.

Creating a New User

  • The syntax to create a new user is: CREATE USER 'username'@'host' IDENTIFIED BY 'password';
  • User is a keyword.
  • username is the name of the user.
  • host is the name of the host on which the user is working (e.g., 'localhost' for local computer).
  • IDENTIFIED BY is a keyword for password authentication.
  • password is the password for the user.

Granting Permissions

  • Granting permissions means specifying what operations a user can perform on which database.
  • The syntax to grant permissions is: GRANT privileges ON database.* TO 'username'@'host';
  • GRANT is a keyword.
  • privileges are the operations the user is allowed to perform (e.g., SELECT, INSERT, UPDATE, DELETE, CREATE, DROP).
  • database.* specifies the database and tables on which the user has permissions.
  • username and host specify the user and host.

Revoking Permissions

  • Revoking permissions means taking away permissions from a user.
  • The syntax to revoke permissions is: REVOKE privileges ON database.* FROM 'username'@'host';
  • REVOKE is a keyword.

Views

  • A view is a logical representation of data in a database, allowing programmers to display predetermined data to users.
  • Views are masks placed upon tables, enabling the development of a method to display data according to the programmer's desire.
  • MySQL creates a temporary table based on the view definition statement and then executes the incoming query on this temporary table.
  • Views are created for reasons including:
    • Avoiding data duplication
    • Simplifying queries
    • Allowing querying as a base table itself
    • Providing data security
    • Avoiding data redundancy

Triggers

  • In MySQL, a trigger is a set of SQL statements that is invoked automatically when a change is made to the data on the associated table.

This quiz covers the concepts of Views and user creation in MySQL, including understanding the USER table and account privileges.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Mastering MySQL
4 questions

Mastering MySQL

SilentPorcupine avatar
SilentPorcupine
MySQL Quiz
10 questions
Introduction to MySQL Basics
36 questions
Introducción a SQL y MySQL
10 questions
Use Quizgecko on...
Browser
Browser