Documentation

Manage authorization with InfluxQL

Important
Authentication must be enabled before authorization can be managed. If authentication is not enabled, permissions will not be enforced. See “Enable authentication”.

We recommend using Chronograf and/or the Enterprise meta API to manage InfluxDB Enterprise users and roles.

Outside of creating users, we recommend operators do not mix and match InfluxQL with other authorization management methods (Chronograf and the API). Doing so may lead to inconsistencies in user permissions.

This page shows examples of basic user and permission management using InfluxQL statements. However, only a subset of Enterprise permissions can be managed with InfluxQL. Using InfluxQL, you can perform the following actions:

  • Create new users and assign them either the admin role (or no role).
  • grant READ and/or WRITE permissions to users. (READ, WRITE, ALL)
  • REVOKE permissions from users.
  • GRANT or REVOKE specific database access to individual users.

However, InfluxDB Enterprise offers an expanded set of permissions. You can use the Meta API and Chronograf to access and assign these more granular permissions to individual users.

The InfluxDB Enterprise meta API provides the most comprehensive way to manage users, roles, permission and other fine grained authorization (FGA) capabilities.

Non-admin users

When authentication is enabled, a new non-admin user has no access to any database until they are specifically granted privileges to a database by an admin user.

Non-admin users can SHOW the databases for which they have ReadData or WriteData permissions.

User management commands

User management commands apply to either admin users, non-admin users, or both.

For more information about these commands, see Database management and Continuous queries.

Manage admin users

Create an admin user with:

CREATE USER admin WITH PASSWORD '<password>' WITH ALL PRIVILEGES
  • Copy
  • Fill window

Repeating the exact CREATE USER statement is idempotent. If any values change the database will return a duplicate user error.

> CREATE USER todd WITH PASSWORD '123456' WITH ALL PRIVILEGES
> CREATE USER todd WITH PASSWORD '123456' WITH ALL PRIVILEGES
> CREATE USER todd WITH PASSWORD '123' WITH ALL PRIVILEGES
ERR: user already exists
> CREATE USER todd WITH PASSWORD '123456'
ERR: user already exists
> CREATE USER todd WITH PASSWORD '123456' WITH ALL PRIVILEGES
>
  • Copy
  • Fill window
GRANT administrative privileges to an existing user
GRANT ALL PRIVILEGES TO <username>
  • Copy
  • Fill window
REVOKE administrative privileges from an admin user
REVOKE ALL PRIVILEGES FROM <username>
  • Copy
  • Fill window
SHOW all existing users and their admin status
SHOW USERS
  • Copy
  • Fill window
CLI Example
> SHOW USERS
user 	   admin
todd     false
paul     true
hermione false
dobby    false
  • Copy
  • Fill window

Manage non-admin users

CREATE a new non-admin user
CREATE USER <username> WITH PASSWORD '<password>'
  • Copy
  • Fill window
CLI example
> CREATE USER todd WITH PASSWORD 'influxdb41yf3'
> CREATE USER alice WITH PASSWORD 'wonder\'land'
> CREATE USER "rachel_smith" WITH PASSWORD 'asdf1234!'
> CREATE USER "monitoring-robot" WITH PASSWORD 'XXXXX'
> CREATE USER "$savyadmin" WITH PASSWORD 'm3tr1cL0v3r'
  • Copy
  • Fill window
Important notes about providing user credentials
  • The user value must be wrapped in double quotes if it starts with a digit, is an InfluxQL keyword, contains a hyphen, or includes any special characters (for example: !@#$%^&*()-).
  • The password string must be wrapped in single quotes. Do not include the single quotes when authenticating requests. We recommend avoiding the single quote (') and backslash (\) characters in passwords. For passwords that include these characters, escape the special character with a backslash (e.g. (\') when creating the password and when submitting authentication requests.
  • Repeating the exact CREATE USER statement is idempotent. If any values change the database will return a duplicate user error.
CLI example
> CREATE USER "todd" WITH PASSWORD '123456'
> CREATE USER "todd" WITH PASSWORD '123456'
> CREATE USER "todd" WITH PASSWORD '123'
ERR: user already exists
> CREATE USER "todd" WITH PASSWORD '123456'
> CREATE USER "todd" WITH PASSWORD '123456' WITH ALL PRIVILEGES
ERR: user already exists
> CREATE USER "todd" WITH PASSWORD '123456'
>
  • Copy
  • Fill window
GRANT READ, WRITE or ALL database privileges to an existing user
GRANT [READ,WRITE,ALL] ON <database_name> TO <username>
  • Copy
  • Fill window

CLI examples:

GRANT READ access to todd on the NOAA_water_database database:

> GRANT READ ON "NOAA_water_database" TO "todd"
  • Copy
  • Fill window

GRANT ALL access to todd on the NOAA_water_database database:

> GRANT ALL ON "NOAA_water_database" TO "todd"
  • Copy
  • Fill window
REVOKE READ, WRITE, or ALL database privileges from an existing user
REVOKE [READ,WRITE,ALL] ON <database_name> FROM <username>
  • Copy
  • Fill window

CLI examples:

REVOKE ALL privileges from todd on the NOAA_water_database database:

> REVOKE ALL ON "NOAA_water_database" FROM "todd"
  • Copy
  • Fill window

REVOKE WRITE privileges from todd on the NOAA_water_database database:

> REVOKE WRITE ON "NOAA_water_database" FROM "todd"
  • Copy
  • Fill window

If a user with ALL privileges has WRITE privileges revoked, they are left with READ privileges, and vice versa.

SHOW a user’s database privileges
SHOW GRANTS FOR <user_name>
  • Copy
  • Fill window

CLI example:

> SHOW GRANTS FOR "todd"
database		            privilege
NOAA_water_database	        WRITE
another_database_name	    READ
yet_another_database_name   ALL PRIVILEGES
one_more_database_name      NO PRIVILEGES
  • Copy
  • Fill window

Manage admin and non-admin users

Reset a user’s password
SET PASSWORD FOR <username> = '<password>'
  • Copy
  • Fill window

CLI example:

> SET PASSWORD FOR "todd" = 'password4todd'
  • Copy
  • Fill window

The password string must be wrapped in single quotes. Do not include the single quotes when authenticating requests.

We recommend avoiding the single quote (') and backslash (\) characters in passwords For passwords that include these characters, escape the special character with a backslash (e.g. (\') when creating the password and when submitting authentication requests.

DROP a user
DROP USER <username>
  • Copy
  • Fill window

CLI example:

> DROP USER "todd"
  • Copy
  • Fill window

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out: