MySQL User Account Management
GRANT and REVOKE Syntax
GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
ON {tbl_name | * | *.* | db_name.*}
TO user_name [IDENTIFIED BY [PASSWORD] 'password']
[, user_name [IDENTIFIED BY 'password'] ...]
[REQUIRE
[{SSL| X509}]
[CIPHER cipher [AND]]
[ISSUER issuer [AND]]
[SUBJECT subject]]
[WITH [GRANT OPTION | MAX_QUERIES_PER_HOUR=#]]
REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
ON {tbl_name | * | *.* | db_name.*}
FROM user_name [, user_name ...]GRANT is implemented in MySQL Version 3.22.11 or later. For earlier MySQL versions, the GRANT statement does nothing.
The GRANT and REVOKE commands allow system administrators to create users and grant and revoke rights to MySQL users at four privilege levels:
- Global level
Global privileges apply to all databases on a given server. These privileges are stored in the mysql.user table.
- Database level
Database privileges apply to all tables in a given database. These privileges are stored in the mysql.db and mysql.host tables.
- Table level
Table privileges apply to all columns in a given table. These privileges are stored in the mysql.tables_priv table.
- Column level
Column privileges apply to single columns in a given table. These privileges are stored in the mysql.columns_priv table.
If you give a grant for a user that doesn’t exist, that user is created. For examples of how GRANT works, see Section 4.3.5.
For the GRANT and REVOKE statements, priv_type may be specified ...