You are viewing an older version of this section. View current production version.
GRANT
Create a user account with the specified privileges.
Syntax
GRANT priv_type [, priv_type [ ... ]] ON priv_level
TO user_or_role [, user_or_role [ ... ]]
[WITH GRANT OPTION]
[REQUIRE {SSL | NONE}]
priv_type:
ALL PRIVILEGES
| SELECT
| INSERT
| UPDATE
| DELETE
| CREATE
| DROP
| RELOAD
| PROCESS
| FILE READ
| FILE WRITE
| INDEX
| ALTER
| SHOW METADATA
| GRANT OPTION
| SUPER
| CREATE TEMPORARY TABLES
| LOCK TABLES
| CREATE VIEW
| SHOW VIEW
| CREATE USER
| CLUSTER
| ALTER VIEW
| DROP VIEW
| BACKUP
| CREATE DATABASE
| DROP DATABASE
| CREATE PIPELINE
| DROP PIPELINE
| ALTER PIPELINE
| START PIPELINE
| SHOW PIPELINE
| EXECUTE
| CREATE ROUTINE
| ALTER ROUTINE
priv_level:
*
| *.*
| database.*
| database.table
user_or_role:
user [, user]
| role
user:
'user_name'@'host_name' [IDENTIFIED BY 'password']
role:
ROLE 'role_name'
Arguments
priv_type: The privileges to grant the specified user.
priv_level: The resource on which to grant privileges.
user_or_role: One or more user attributes or a role attribute.
Remarks
- The
GRANT
command creates a new user if the specified username does not exist. - A user with
SUPER
permission can perform the following actions:- Set global variables, run administrative commands, and change password for other users.
- Access all available resource pools. Permissions for additional resource pools can be given using the
GRANT
command.
- The
WITH GRANT OPTION
clause grants theGRANT OPTION
privilege, which allows a user to grant any privilege that the user already has to other users within a scoped database. TheGRANT ... WITH GRANT OPTION
andGRANT GRANT OPTION ...
statements are synonymous to each other. See GRANT for more information. Note: Different users withGRANT OPTION
privilege may be able to combine their privileges. A user with both theGRANT OPTION
andSUPER
privileges can grant any privilege to the users (including themselves) within a scoped database. - This command can be run on any SingleStore node. For more information, see the Node Requirements for SingleStore DB Commands.
Examples
The following example demonstrates how to grant privileges to the existing memsql_admin
user:
memsql> GRANT ALL PRIVILEGES ON *.* TO 'memsql_admin'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
The following example demonstrates how to grant the specified privileges to all databases to the full_backups_role
role.
memsql> GRANT BACKUP, RELOAD ON *.* TO ROLE 'full_backups_role';
If you removed ROLE
from the example above, the GRANT
command would apply privileges to the user 'full_backup_role'@'%'
.
The following example demonstrates how to grant permissions for a resource pool to a user:
GRANT USAGE ON RESOURCE POOL <resource_pool_name> to '<user_name>'@'%';
Related Topics