You are on page 1of 16

Unit 2 Practice – Data Access 06/10/2023

Document the exercises with screenshots of the commands used and their
results.

1) Recover/change the root password for MariaDB.

2)
Create users and assign permissions locally.
a) Create a user named paco@localhost with connection-only permissions
and verify that the connection is successful.
b) Grant SELECT permissions on the table jardineria.Clientes to the user
paco@localhost and verify that the connection is successful, then
perform a SELECT.
c) Create the user juan@localhost with SELECT, INSERT, and UPDATE
permissions on the tables of the jardineria database with the GRANT
option.
d) Connect with the user juan and grant SELECT permissions on the table
jardineria.Empleados to paco.
e) Revoke SELECT permissions on the table jardineria.Clientes from paco.
f) Connect with root and revoke all the permissions granted to paco and
juan.
g) Grant juan SELECT permissions on the columns CodigoOficina and
Ciudad of the table Oficinas in the jardineria database.
h) Connect with juan and execute the query "SELECT * FROM
jardineria.Oficinas". What happens?
This will allow him to execute the SELECT on OFICINAS table.

i) Delete the user paco@localhost.


3) Query the MySQL metadata catalog
a) Utilizing the mysql.user and mysql.tables_priv tables, create a query to
retrieve the privileges that users have on the tables of the DBMS.
b) Using the tables from the information_schema database, display the
time in minutes since the server has been running.
c) With the views table in the information_schema database, query the
definition of views created in the DBMS.
d) Query the number of rows that each table in the nba database contains.

e) Display the columns of the Empleados table in the jardineria database.


4) Working with views in MySQL
a) With the jardineria database, create the view "CuentaPedidosMadrid"
that displays the fields NombreCliente, NombreContacto, and
NumeroDePedidos ordered in ascending order for all clients in Madrid.

b) Create a user x@localhost and grant SELECT permissions on the fields


NombreCliente and NumeroDePedidos of the view
"CuentaPedidosMadrid" and SELECT permissions on the Clients table.

c) With the user x@localhost, execute a query that, using the


"CuentaPedidosMadrid" view and the Clients table, displays the postal
address and phone number of the top 5 clients in Madrid with the most
orders.
d) Create a view named "Top5Madrid" that shows the same information.
Grant SELECT permissions to x@localhost.
e) Now, revoke the SELECT permissions from x@localhost on
CuentaPedidosMadrid and Clients, reconnect with x@localhost, and try
to do a "SELECT * FROM Top5Madrid". Is it possible?

You might also like