Database Reference
In-Depth Information
To set rights the
GRANT
statement is used. At a minimum,
GRANT
requires that
you specify
The privilege being granted
■
The database or table being granted access to
■
The user name
■
The following example demonstrates the use of
GRANT
:
▼
Input
GRANT SELECT ON crashcourse.* TO bforta;
▼
Analysis
This
GRANT
allows the use of
SELECT
on
crashcourse.*
(
crashcourse
database, all tables). By granting
SELECT
access only, user
bforta
has read-
only access to all data in the
crashcourse
database.
SHOW GRANTS
reflects this change:
▼
Input
SHOW GRANTS FOR bforta;
▼
Output
+-------------------------------------------------+
| Grants for bforta@% |
+-------------------------------------------------+
| GRANT USAGE ON *.* TO 'bforta'@'%' |
| GRANT SELECT ON 'crashcourse'.* TO 'bforta'@'%' |
+-------------------------------------------------+
▼
Analysis
Each
GRANT
adds (or updates) a permission statement for the user. MariaDB
reads all the grants and determines the rights and permissions based on them.
The opposite of
GRANT
is
REVOKE
, which is used to revoke specific rights and
permissions. Here is an example:
▼
Input
REVOKE SELECT ON crashcourse.* FROM bforta;