Until MariaDB 5.5, the mysql.host
table contained information about hosts and their related privileges. When determining permissions, if a matching record in the mysql.db table had a blank host value, the mysql.host table would be examined.
This table is not effected by an GRANT statements, and had to be updated manually.
See privileges for a more complete view of the MariaDB privilege system.
In MariaDB 10.0 and later, this table is no longer used.
In MariaDB 10.3 and before, this table was created the MyISAM storage engine.
In MariaDB 10.4 and later, this table is no longer created. However if the table is created it will be used.
The mysql.host
table contains the following fields:
Field | Type | Null | Key | Default | Description |
---|---|---|---|---|---|
Host |
char(60) |
NO | PRI | Host (together with Db makes up the unique identifier for this record. |
|
Db |
char(64) |
NO | PRI | Database (together with Host makes up the unique identifier for this record. |
|
Select_priv |
enum('N','Y') |
NO | N | Can perform SELECT statements. | |
Insert_priv |
enum('N','Y') |
NO | N | Can perform INSERT statements. | |
Update_priv |
enum('N','Y') |
NO | N | Can perform UPDATE statements. | |
Delete_priv |
enum('N','Y') |
NO | N | Can perform DELETE statements. | |
Create_priv |
enum('N','Y') |
NO | N | Can CREATE TABLEs. | |
Drop_priv |
enum('N','Y') |
NO | N | Can DROP DATABASEs or DROP TABLEs. | |
Grant_priv |
enum('N','Y') |
NO | N | User can 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 statement. Without the INDEX privilege, user can still create indexes when creating a table using the CREATE TABLE statement if the user has have the CREATE privilege, and user can create indexes using the ALTER TABLE statement if they have the ALTER privilege. |
|
Alter_priv |
enum('N','Y') |
NO | N | Can perform ALTER TABLE statements. | |
Create_tmp_table_priv |
enum('N','Y') |
NO | N | Can create temporary tables with the CREATE TEMPORARY TABLE statement. | |
Lock_tables_priv |
enum('N','Y') |
NO | N | Acquire explicit locks using the 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 statement. | |
Show_view_priv |
enum('N','Y') |
NO | N | Can show the CREATE VIEW statement to create a view using the SHOW CREATE VIEW statement. | |
Create_routine_priv |
enum('N','Y') |
NO | N | Can create stored programs using the CREATE PROCEDURE and CREATE FUNCTION statements. | |
Alter_routine_priv |
enum('N','Y') |
NO | N | Can change the characteristics of a stored function using the ALTER FUNCTION statement. | |
Execute_priv |
enum('N','Y') |
NO | N | Can execute stored procedure or functions. | |
Trigger_priv |
enum('N','Y') |
NO | N | Can execute triggers associated with tables the user updates, execute the CREATE TRIGGER and DROP TRIGGER statements. |
If you need the functionality to only allow access to your database from a given set of hosts, you can create the host table with the following command:
CREATE TABLE IF NOT EXISTS mysql.host (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY /*Host*/ (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges';
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/mysqlhost-table/