1
0
Fork 0
mirror of https://github.com/imjasonh/gcloud-help synced 2026-07-08 18:45:13 +00:00
gcloud-help/gcloud/sql/users/assign-roles
2026-02-11 11:28:25 +00:00

81 lines
3 KiB
Text

NAME
gcloud sql users assign-roles - updates a user's database roles in a given
instance
SYNOPSIS
gcloud sql users assign-roles USERNAME --instance=INSTANCE, -i INSTANCE
--type=TYPE [--async] [--database-roles=[ROLE,...]] [--host=HOST]
[--revoke-existing-roles] [GCLOUD_WIDE_FLAG ...]
DESCRIPTION
Updates a user's database roles in a given instance with a specified
username and host.
EXAMPLES
To grant database roles role1 and role2 for my-user in instance
prod-instance, run:
$ gcloud sql users assign-roles my-user --instance=prod-instance \
--database-roles=role1,role2 --type=BUILT_IN
To revoke existing database roles and grant new database roles role3 and
role4 for my-user in instance prod-instance, run:
$ gcloud sql users assign-roles my-user --instance=prod-instance \
--revoke-existing-roles --database-roles=role3,role4 \
--type=BUILT_IN
POSITIONAL ARGUMENTS
USERNAME
Cloud SQL username.
REQUIRED FLAGS
--instance=INSTANCE, -i INSTANCE
Cloud SQL instance ID.
--type=TYPE
Cloud SQL user's type. It determines the method to authenticate the
user during login. See the list of user types at
https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/SqlUserType
OPTIONAL FLAGS
--async
Return immediately, without waiting for the operation in progress to
complete.
--database-roles=[ROLE,...]
A comma-separated list of database roles to be assigned to the user.
This option is only available for MySQL and PostgreSQL instances. You
can include predefined Cloud SQL roles, like cloudsqlsuperuser, or your
own custom roles. Custom roles must be created in the database before
you can assign them. You can create roles using the CREATE ROLE
statement for both MySQL and PostgreSQL.
--host=HOST
Cloud SQL user's hostname expressed as a specific IP address or address
range. % denotes an unrestricted hostname. Applicable flag for MySQL
instances; ignored for all other engines. Note, if you connect to your
instance using IP addresses, you must add your client IP address as an
authorized address, even if your hostname is unrestricted. For more
information, see Configure IP
(https://cloud.google.com/sql/docs/mysql/configure-ip).
--revoke-existing-roles
A boolean flag for revoking existing database roles from the user. This
option is only available for MySQL and PostgreSQL instances.
GCLOUD WIDE FLAGS
These flags are available to all commands: --access-token-file, --account,
--billing-project, --configuration, --flags-file, --flatten, --format,
--help, --impersonate-service-account, --log-http, --project, --quiet,
--trace-token, --user-output-enabled, --verbosity.
Run $ gcloud help for details.
NOTES
These variants are also available:
$ gcloud alpha sql users assign-roles
$ gcloud beta sql users assign-roles