The MySQL Access Privilege System

Here, in this section you will study about different Access Privilege Systems.

Privileges Provided by MySQL

Here, MySQL provides privileges that apply in different contexts and at different levels of operation:
Administrative privileges allow users to manage operation of the MySQL server. These privileges are global because they are not specific to a particular database.

Database privileges apply to a database and to all objects within it. These privileges can be granted for specific databases, or globally so that they apply to all databases.

Privileges for database objects such as tables, indexes, views, and stored routines can be granted for specific objects within a database, for all objects of a given type within a database.
Privilege System Grant Tables

Normally, a user manipulate the contents of the grant tables in the mysql database indirectly by using statements such as GRANT and REVOKE to set up accounts and control the privileges available to each one.

These mysql database tables contain grant information:
user: It contains user accounts, global privileges, and other non-privilege columns.

db: It contains database-level privileges.

host: It is Obsolete. New MySQL installations no longer create this table as of MySQL 5.6.7.

tables_priv: It contains table-level privileges.

columns_priv: It contains column-level privileges.

procs_priv: It contains stored procedure and function privileges.

proxies_priv: It contains proxy-user privileges.
Specifying Account Names

MySQL account names consist of a username and a hostname. This allows creation of accounts for users with the same name who can connect from different hosts.

Here in this section you will learn how to write account names, including special values and wildcard rules.
Syntax for account names is ‘user_name’@’host_name’.
An account name consisting only of a username is equivalent to ‘user_name’@’%’.
The username and hostname need not be quoted if they are legal as unquoted identifiers. Quotes are necessary to specify a user_name string containing special characters (such as “-”), or a host_name string containing special characters or wildcard characters (such as “%”);.
Quote usernames and hostnames as identifiers or as strings, using either backticks (“`”), single quotation marks (“’”), or double quotation marks (“””).
The username and hostname parts, if quoted, must be quoted separately.
A reference to the CURRENT_USER or CURRENT_USER() function is equivalent to specifying the current client’s username and hostname literally.