3 - Mariadb Revoke

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

MariaDB REVOKE

Suppose rfc account has privileges SELECT, UPDATE and DELETE in the classicmodels
sample database . If you want to revoke UPDATE and DELETE privileges from the rfc account,
you can do so as follows:
First, you check the privileges of rfc account using SHOW GRANTS statement:
MariaDB
1 SHOW GRANTS FOR 'rfc'@'localhost';
MariaDB
1 GRANT SELECT, UPDATE, DELETE ON 'classicmodels'.* TO 'rfc'@'localhost'
If you have not followed the previous lab on granting privileges to user, you can first grant the
SELECT, UPDATE and DELETE privileges for rfc account that connects from localhost to the
classicmodels database as follows:
MariaDB
1 GRANT SELECT, UPDATE, DELETE ON classicmodels.* TO 'rfc'@'localhost';
Second, you can revoke the UPDATE and DELETE privileges from the rfc account:
MariaDB
1 REVOKE UPDATE, DELETE ON classicmodels.* FROM 'rfc'@'localhost';
Third, you can check the privileges of the rfc account again using the SHOW GRANTS
command.
MariaDB
1 SHOW GRANTS FOR 'rfc'@'localhost';
MariaDB
1 GRANT SELECT ON 'classicmodels'.* TO 'rfc'@'localhost'
If you want to revoke all privileges of the rfc account, you run the following command:
MariaDB
1 REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'rfc'@'localhost';
If you check the privileges of the rfc account again, you will see the rfc account has no privilege.

MariaDB
1 SHOW GRANTS FOR 'rfc'@'localhost';
MariaDB
1 GRANT USAGE ON *.* TO 'rfc'@'localhost'
Note that USAGE privilege means no privileges in MariaDB.

When MariaDB REVOKE takes effect


The effect of MariaDB REVOKE statement depends on the privilege level as follows:

Changes that are made to the global privileges only take effect when the client connects
to the MariaDB in the subsequent sessions. The changes are not applied to all currently
connected accounts.
The change of database privileges is applied after the next USE statement.
Table and column privileges changes are applied to all queries that are issued after the
changes are made.

You might also like