Skip to main content

MySQL Privileges

In MySQL, privileges determine what operations a user can perform on the database. They are classified into three main categories:


Data Privileges

🧾 Allow the user to directly manipulate the information stored in the tables (read, insert, update or delete data).

No.PrivilegeWhat does it allow?Activity to perform
1SELECTRead data from a table.Write a query to get products with a price greater than 100.
2INSERTInsert records into a table.Add a new customer to the customers table.
3UPDATEModify existing records.Update the email of a specific user.
4DELETEDelete records.Delete products whose stock is 0.
5FILERead/write system files from the database.Load a CSV file from the server into a table.

Structure Privileges

🧾 Allow modifying the structure of databases and their objects: create, alter or drop tables, views, procedures, among others.

No.PrivilegeWhat does it allow?Activity to perform
6CREATECreate new tables or databases.Create a table named orders.
7ALTERModify the structure of an existing table.Add a shipping_date column to the orders table.
8DROPDelete structures like tables.Delete the obsolete_products table.
9INDEXCreate or delete indexes.Create an index on the email field of the users table.
10CREATE TEMPORARY TABLESCreate temporary tables.Create a temporary table to store intermediate results.
11SHOW VIEWQuery views.Query and explain what the monthly_sales view shows.
12CREATE VIEWCreate new views.Generate a view showing customers with more than 3 purchases.
13TRIGGERCreate triggers.Create a trigger that logs every time a sale is inserted.
14EVENTCreate scheduled events.Create an event that deletes old records every month.
15CREATE ROUTINECreate procedures or functions.Create a routine to apply a discount to all products.
16ALTER ROUTINEModify existing routines.Modify a procedure to receive a new parameter.
17EXECUTEExecute functions or procedures.Execute a function that calculates total sales per customer.

Administration Privileges

🧾 Grant database system management capabilities, such as creating users, assigning permissions, monitoring processes or configuring replication.

No.PrivilegeWhat does it allow?Activity to perform
18GRANTAssign privileges to other users.Grant read permissions to a new user.
19SUPERExecute advanced administrative operations.Simulate changing a global variable.
20PROCESSView active processes on the server.Display active processes and kill a specific one.
21RELOADReload tables and privileges from disk.Simulate reloading permissions after a change.
22SHUTDOWNShut down the MySQL server.(Do not perform) Only investigate the shutdown process.
23SHOW DATABASESView all available databases.List databases accessible to the current user.
24LOCK TABLESLock tables for exclusive use.Lock a table, perform an operation and unlock it.
25REFERENCESUse foreign keys.Create a relationship between customers and orders.
26REPLICATION CLIENTQuery replication status.Query the replication binlog status.
27REPLICATION SLAVEAct as a replica in replication.Investigate how to configure a replica database.
28CREATE USERCreate new database users.Create a user with read-only permissions.

Activity

If you made it this far, congratulations! This activity is not graded, but the knowledge you will acquire if you develop it will be monumental.
You will see how to precisely control what each user can do in your database... like a true expert administrator.

Objective

Understand the meaning, use, and application of the different privileges in MySQL classified into:

  • 📂 Data
  • 🏗️ Structure
  • ⚙️ Administration

Through this activity, participants will explore what each privilege allows and build functional examples demonstrating their use within a practical database context.


Instructions

  1. Research: For each listed privilege, provide a brief explanation in your own words (maximum 2 lines) about what it allows and why it would be useful in a real system.

  2. Application: Create a practical example in Markdown (.md) for each of the privileges. This example must include:

    • A context table (real or simulated).
    • A small SQL code block demonstrating the use of the privilege.
    • A brief description of the objective of that code.