Influxdb Command

Basic Command

Connect

1
2
3
4
influx -precision rfc3339

# The -precision argument specifies the format/precision of any returned timestamps
# rfc3339 tells InfluxDB to return timestamps in RFC3339 format (YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ)

Auth

  1. Auth User

    1
    auth
  2. Authenticate Telegraf requests to InfluxDB

    1
    2
    3
    4
    5
    ## Write timeout (for the InfluxDB client), formatted as a string.
    ## If not provided, will default to 5s. 0s means no timeout (not recommended).
    timeout = "5s"
    username = "telegraf" #💥
    password = "metricsmetricsmetricsmetrics" #💥

Create DB

1
CREATE DATABASE mydb

Drop DB

1
DROP DATABASE

Permission Management

Admin user management

1
2
3
4
CREATE USER
GRANT ALL PRIVILEGES
REVOKE ALL PRIVILEGES
SHOW USERS

Non-admin user management:

1
2
3
4
CREATE USER
GRANT [READ,WRITE,ALL]
REVOKE [READ,WRITE,ALL]
SHOW GRANTS

Case

1
2
3
4
5
# create admin user
CREATE USER <username> WITH PASSWORD '<password>' WITH ALL PRIVILEGES

# create normal user
CREATE USER <username> WITH PASSWORD '<password>'
1
2
# add database permission to user
GRANT [READ,WRITE,ALL] ON <database_name> TO <username>
1
REVOKE ALL PRIVILEGES FROM <username>
1
SET PASSWORD FOR <username> = '<password>'
1
DROP USER <username>

Measurement

1
2
3
4
5
SHOW MEASUREMENTS

DELETE FROM MEASUREMENT

SELECT * FROM MEASUREMENT

Reference