Join the SingleStore Community Today
Get expert advice, develop skills, and connect with others.

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
    | SUPER
    | CREATE TEMPORARY TABLES
    | LOCK TABLES
    | REPLICATION
    | 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.

This command can be run on any SingleStore node. For more information, see the Node Requirements for SingleStore DB Commands.

SingleStore Managed Service

Run the following to create a new user with all of the permissions that are currently available on SingleStore Managed Service.

GRANT 
  SELECT
  ,CREATE USER
  ,INSERT
  ,UPDATE
  ,DELETE
  ,CREATE
  ,INDEX
  ,ALTER
  ,DROP
  ,CREATE TEMPORARY TABLES
  ,CREATE 
  ,SHOW VIEW
  ,ALTER VIEW
  ,DROP VIEW
  ,BACKUP
  ,CREATE DATABASE
  ,DROP DATABASE
  ,CREATE PIPELINE
  ,DROP PIPELINE
  ,ALTER PIPELINE
  ,START PIPELINE
  ,SHOW PIPELINE
  ,CREATE ROUTINE
  ,ALTER ROUTINE
  ,EXECUTE
  ,USAGE
  ,RELOAD
  ,LOCK TABLES
ON TEST_DM.* 
TO 'TEST_DBA';

Note that the following permissions are currently not available with SingleStore Managed Service.

priv_type:
      ALL PRIVILEGES
    | PROCESS
    | FILE READ
    | FILE WRITE
    | SHOW METADATA
    | REPLICATION
    | CLUSTER

For SingleStore Managed Service, GRANT permissions must be scoped to specific actions contained within the database. As a consequence, GRANT ALL is not supported in SingleStore Managed Service because it includes cluster-wide permissions that are outside the scope of the managed service.

For example:

GRANT ALL PRIVILEGES ON *.* TO 'memsql_admin'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

In addition, cluster-level statements are not supported as SingleStore Managed Service clusters are managed by SingleStore DB.

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';
Info

If you removed ROLE from the example above, the GRANT command would apply privileges to the user 'full_backup_role'@'%'.

Related Topics