Difference between revisions of "MariaDB/SQL/GRANT"
Jump to navigation
Jump to search
m (→Example: backticks) |
|||
| (2 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
* <code>{{l/same|REVOKE}}</code> negates privileges granted by <code>GRANT</code>. | * <code>{{l/same|REVOKE}}</code> negates privileges granted by <code>GRANT</code>. | ||
* <code>{{l/same|SHOW GRANTS}}</code> lists privileges granted by <code>GRANT</code>. (see <code>{{l/same|SHOW}}</code>) | * <code>{{l/same|SHOW GRANTS}}</code> lists privileges granted by <code>GRANT</code>. (see <code>{{l/same|SHOW}}</code>) | ||
| + | ==Reference== | ||
| + | * [https://mariadb.com/kb/en/grant/ MariaDB Knowledge Base] | ||
| + | ==Example== | ||
| + | * <syntaxhighlight inline lang=SQL>GRANT ALL ON `roundcube`.* to 'rc-bot'@localhost;</syntaxhighlight> | ||
| + | |||
==Syntax== | ==Syntax== | ||
* <code>GRANT</code> {{fmt/arg|priv list}} <code>ON</code> {{fmt/arg|object type}} {{fmt/arg|priv level}} <code>TO</code> {{fmt/arg|user spec}} [ {{fmt/arg|user options}} ] | * <code>GRANT</code> {{fmt/arg|priv list}} <code>ON</code> {{fmt/arg|object type}} {{fmt/arg|priv level}} <code>TO</code> {{fmt/arg|user spec}} [ {{fmt/arg|user options}} ] | ||
| Line 8: | Line 13: | ||
*** <code>USAGE</code> | *** <code>USAGE</code> | ||
*** <code>ALL</code> [<code>PRIVILEGES</code>] | *** <code>ALL</code> [<code>PRIVILEGES</code>] | ||
| − | |||
** '''{{fmt/arg|object type}}''': ''one of –'' | ** '''{{fmt/arg|object type}}''': ''one of –'' | ||
*** <code>TABLE</code> | *** <code>TABLE</code> | ||
| Line 25: | Line 29: | ||
*** {{fmt/arg|username}} {{fmt/arg/opt|authentication option}} | *** {{fmt/arg|username}} {{fmt/arg/opt|authentication option}} | ||
*** <code>PUBLIC</code> | *** <code>PUBLIC</code> | ||
| − | ** '''{{fmt/arg | + | ** '''{{fmt/arg|authentication option}}''': ''one of –'' |
*** <code>IDENTIFIED BY</code> '{{fmt/arg|password}}' | *** <code>IDENTIFIED BY</code> '{{fmt/arg|password}}' | ||
*** <code>IDENTIFIED BY PASSWORD</code> 'password_hash' | *** <code>IDENTIFIED BY PASSWORD</code> 'password_hash' | ||
*** <code>IDENTIFIED</code> {<code>VIA</code>|<code>WITH</code>} {{fmt/arg|authentication rule}} [OR ''repeat...''] | *** <code>IDENTIFIED</code> {<code>VIA</code>|<code>WITH</code>} {{fmt/arg|authentication rule}} [OR ''repeat...''] | ||
| + | ** '''{{fmt/arg|user option}}''': ''one of –'' | ||
| + | *** <code>REQUIRE</code> {<code>NONE</code> | {{fmt/arg|TLS option}} [[<code>AND</code>] ''repeat...''] | ||
| + | *** [<code>WITH</code> {{fmt/arg|with option}} [''repeat...''] | ||
| + | ** '''{{fmt/arg|with option}}''': ''one of –'' | ||
| + | *** <code>GRANT OPTION</code> | ||
| + | *** {{fmt/arg|resource_option}} | ||
* <code>GRANT</code> {{fmt/arg|rolename}} <code>TO</code> {{fmt/arg|grantee}} [, ''repeat...''] [<code>WITH ADMIN OPTION</code>] | * <code>GRANT</code> {{fmt/arg|rolename}} <code>TO</code> {{fmt/arg|grantee}} [, ''repeat...''] [<code>WITH ADMIN OPTION</code>] | ||
** '''{{fmt/arg|grantee}}''': ''one of –'' | ** '''{{fmt/arg|grantee}}''': ''one of –'' | ||
*** {{fmt/arg|rolename}} | *** {{fmt/arg|rolename}} | ||
*** {{fmt/arg|username}} {{fmt/arg/opt|authentication option}} | *** {{fmt/arg|username}} {{fmt/arg/opt|authentication option}} | ||
Latest revision as of 17:36, 13 April 2025
Related
REVOKEnegates privileges granted byGRANT.SHOW GRANTSlists privileges granted byGRANT. (seeSHOW)
Reference
Example
GRANT ALL ON `roundcube`.* to 'rc-bot'@localhost;
Syntax
GRANT<priv list>ON<object type> <priv level>TO<user spec> [ <user options> ]- <priv list>: <priv_type> [ <column_list> ] [, repeat...]
- <priv_type>: one of –
USAGEALL[PRIVILEGES]
- <object type>: one of –
TABLEFUNCTIONPROCEDUREPACKAGEPACKAGE BODY
- <priv level>: one of –
**.*- <db_name>
.* - <db_name>
.<tbl_name> - <tbl_name>
- <db_name>
.<routine_name>
- <user spec>: one of –
- <username> [ <authentication option> ]
PUBLIC
- <authentication option>: one of –
IDENTIFIED BY'<password>'IDENTIFIED BY PASSWORD'password_hash'IDENTIFIED{VIA|WITH} <authentication rule> [OR repeat...]
- <user option>: one of –
REQUIRE{NONE| <TLS option> [[AND] repeat...]- [
WITH<with option> [repeat...]
- <with option>: one of –
GRANT OPTION- <resource_option>
GRANT<rolename>TO<grantee> [, repeat...] [WITH ADMIN OPTION]- <grantee>: one of –
- <rolename>
- <username> [ <authentication option> ]
- <grantee>: one of –