# mysql.db Table

The `mysql.db` table contains information about database-level privileges. The table can be queried and although it is possible to directly update it, it is best to use [GRANT](https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/grant) for setting privileges.

Note that the MariaDB privileges occur at many levels. A user may not be granted a privilege at the database level, but may still have permission on a table level, for example. See [privileges](https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/grant) for a more complete view of the MariaDB privilege system.

This table uses the [Aria](https://mariadb.com/docs/server/server-usage/storage-engines/aria) storage engine.

The `mysql.db` table contains the following fields:

| Field                    | Type          | Null | Key | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------ | ------------- | ---- | --- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Host                     | char(60)      | NO   | PRI |         | Host (together with User and Db makes up the unique identifier for this record. Until MariaDB 5.5, if the host field was blank, the corresponding record in the [mysql.host](https://mariadb.com/docs/server/reference/system-tables/the-mysql-database-tables/obsolete-mysql-database-tables/mysql-host-table) table would be examined. From MariaDB 10.0, a blank host field is the same as the % wildcard.                                                                                                                                                                                 |
| Db                       | char(64)      | NO   | PRI |         | Database (together with User and Host makes up the unique identifier for this record.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| User                     | char(80)      | NO   | PRI |         | User (together with Host and Db makes up the unique identifier for this record.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Select\_priv             | enum('N','Y') | NO   |     | N       | Can perform [SELECT](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select) statements.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| Insert\_priv             | enum('N','Y') | NO   |     | N       | Can perform [INSERT](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert) statements.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Update\_priv             | enum('N','Y') | NO   |     | N       | Can perform [UPDATE](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/update) statements.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Delete\_priv             | enum('N','Y') | NO   |     | N       | Can perform [DELETE](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/delete) statements.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Create\_priv             | enum('N','Y') | NO   |     | N       | Can [CREATE TABLE's](https://mariadb.com/docs/server/server-usage/tables/create-table).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Drop\_priv               | enum('N','Y') | NO   |     | N       | Can [DROP DATABASE's](https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-database) or [DROP TABLE's](https://mariadb.com/docs/server/server-usage/tables/drop-table).                                                                                                                                                                                                                                                                                                                                                                                         |
| Grant\_priv              | enum('N','Y') | NO   |     | N       | User can [grant](https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/grant) privileges they possess.                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| References\_priv         | enum('N','Y') | NO   |     | N       | Unused                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Index\_priv              | enum('N','Y') | NO   |     | N       | Can create an index on a table using the [CREATE INDEX](https://mariadb.com/docs/server/reference/sql-statements/data-definition/create/create-index) statement. Without the INDEX privilege, user can still create indexes when creating a table using the [CREATE TABLE](https://mariadb.com/docs/server/server-usage/tables/create-table) statement if the user has have the CREATE privilege, and user can create indexes using the [ALTER TABLE](https://mariadb.com/docs/server/reference/sql-statements/data-definition/alter/alter-table) statement if they have the ALTER privilege. |
| Alter\_priv              | enum('N','Y') | NO   |     | N       | Can perform [ALTER TABLE](https://mariadb.com/docs/server/reference/sql-statements/data-definition/alter/alter-table) statements.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Create\_tmp\_table\_priv | enum('N','Y') | NO   |     | N       | Can create temporary tables with the [CREATE TEMPORARY TABLE](https://mariadb.com/docs/server/server-usage/tables/create-table) statement.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Lock\_tables\_priv       | enum('N','Y') | NO   |     | N       | Acquire explicit locks using the [LOCK TABLES](https://mariadb.com/docs/server/reference/sql-statements/transactions/lock-tables) statement; user also needs to have the SELECT privilege on a table in order to lock it.                                                                                                                                                                                                                                                                                                                                                                     |
| Create\_view\_priv       | enum('N','Y') | NO   |     | N       | Can create a view using the [CREATE\_VIEW](https://mariadb.com/docs/server/server-usage/views/create-view) statement.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Show\_view\_priv         | enum('N','Y') | NO   |     | N       | Can show the [CREATE VIEW](https://mariadb.com/docs/server/server-usage/views/create-view) statement to create a view using the [SHOW CREATE VIEW](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/show/show-create-view) statement.                                                                                                                                                                                                                                                                                                                   |
| Create\_routine\_priv    | enum('N','Y') | NO   |     | N       | Can create stored programs using the [CREATE PROCEDURE](https://mariadb.com/docs/server/server-usage/stored-routines/stored-procedures/create-procedure) and [CREATE FUNCTION](https://mariadb.com/docs/server/reference/sql-statements/data-definition/create/create-function) statements.                                                                                                                                                                                                                                                                                                   |
| Alter\_routine\_priv     | enum('N','Y') | NO   |     | N       | Can change the characteristics of a stored function using the [ALTER FUNCTION](https://mariadb.com/docs/server/reference/sql-statements/data-definition/alter/alter-function) statement.                                                                                                                                                                                                                                                                                                                                                                                                      |
| Execute\_priv            | enum('N','Y') | NO   |     | N       | Can execute [stored procedure](https://mariadb.com/docs/server/server-usage/stored-routines/stored-procedures) or functions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Event\_priv              | enum('N','Y') | NO   |     | N       | Create, drop and alter [events](https://mariadb.com/docs/server/server-usage/triggers-events/event-scheduler).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Trigger\_priv            | enum('N','Y') | NO   |     | N       | Can execute [triggers](https://mariadb.com/docs/server/server-usage/triggers-events/triggers) associated with tables the user updates, execute the [CREATE TRIGGER](https://mariadb.com/docs/server/server-usage/triggers-events/triggers/create-trigger) and [DROP TRIGGER](https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-trigger) statements.                                                                                                                                                                                                          |
| Delete\_history\_priv    | enum('N','Y') | NO   |     | N       | Can delete rows created through [system versioning](https://mariadb.com/docs/server/reference/sql-structure/temporal-tables/system-versioned-tables).                                                                                                                                                                                                                                                                                                                                                                                                                                         |

The [Acl\_database\_grants](https://mariadb.com/docs/server/server-management/variables-and-modes/server-status-variables#acl_database_grants) status variable indicates how many rows the `mysql.db` table contains.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
