All Products
Search
Document Center

Time Series Database:CLI of TSDB for InfluxDB®

Last Updated:Aug 25, 2026

The command-line interface (influx) of TSDB for InfluxDB® is a shell that interacts with the HTTP API. You can use influx to write data manually or from files, query data interactively, and view query results in different formats.

Download the CLI

Download the binary package for your operating system from the following links:

Extract the downloaded package and go to the extracted folder. The folder contains the command-line tool influx (influx.exe on Windows).

Start influx

Start influx in your terminal. After you connect to the TSDB for InfluxDB® instance, the following output is displayed:

$ ./influx -ssl -username "myname" -password "mypassword" -host ts-xxxxxx.influxdata.rds.aliyuncs.com -port 3242
Connected to https://<Endpoint>:3242 version 1.8.x
InfluxDB shell version: 1.8.x

TSDB for InfluxDB® uses SSL to secure data in transit. The -ssl, -username, -password, -host, and -port parameters are required each time you connect to TSDB for InfluxDB®.

Parameter description

  • -ssl: connects to the InfluxDB server over HTTPS.

  • -username: the username of the account that you created.

  • -password: the password of the account.

  • -host: the endpoint of the instance. Replace ts-xxxxxx with your instance ID.

  • -port: the network port. Use 8086 for VPC connections and 3242 for Internet connections.

You can now enter InfluxQL queries and some CLI commands directly in your terminal. To enter Flux queries, set the -type option to flux. You can run help at any time to list the available commands. To interrupt a long-running InfluxQL query, press Ctrl+C.

Environment variables

The following environment variables can be used to configure the settings of the influx client. You can specify them in lowercase or uppercase. Uppercase takes precedence.

HTTP_PROXY

Defines the proxy server that HTTP uses.

Value format: [protocol://][:port]

HTTP_PROXY=http://localhost:1234

HTTPS_PROXY

Defines the proxy server that HTTPS uses. If both HTTP_PROXY and HTTPS_PROXY are set, HTTPS_PROXY takes precedence.

Value format: [protocol://][:port]

HTTPS_PROXY=https://localhost:1443

NO_PROXY

A list of host names that do not go through any proxy. If this variable is set to only an asterisk (*), it matches all hosts.

Value format: separate multiple hosts with commas.

NO_PROXY=123.45.67.89,123.45.67.90

influx options

You can pass options to influx when you start influx. Run $ influx --help to list the available options. The following list briefly describes each option. The -execute, -format, and -import options are described in detail later in this section.

-compressed

Set this option to true if the import file is compressed. -compressed must be used together with -import.

Sets the write consistency level.

-database 'database name'

The database that influx connects to.

-execute '<command>'

Runs an InfluxQL command and exits.

-format 'json|csv|column'

Specifies the format of the server responses.

-host '<hostname>'

The host that influx connects to.

-import

Imports new data from a file, or imports a database that was previously exported to a file.

-password '<password>'

The password that influx uses to connect to the server. If you leave this option empty (-password ''), influx prompts you for the password. You can also use the INFLUX_PASSWORD environment variable to set the password for the CLI.

-path

The path to the import file. -path must be used together with -import.

-port 'port #'

The port that influx connects to. By default, TSDB for InfluxDB® runs on port 3242.

-pps

The number of data points per second that the import allows. By default, pps is set to 0 and influx does not limit the import rate. -pps must be used together with -import.

-precision 'rfc3339|h|m|s|ms|u|ns'

Specifies the format and precision of the timestamps for queries and writes: rfc3339 (YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ), h (hours), m (minutes), s (seconds), ms (milliseconds), u (microseconds), or ns (nanoseconds). The default precision is nanoseconds.

-pretty

Pretty-prints the JSON output for readability.

-ssl

Uses HTTPS for requests.

-type

Determines which interactive shell to use. The default value is influxql. To use the Flux REPL shell, set -type to flux.

-username 'username'

The username that influx uses to connect to the server. You can also use the INFLUX_USERNAME environment variable to set the username for the CLI.

-version

Displays the version of TSDB for InfluxDB® and exits.

Use -execute to run an InfluxQL command and exit

Run a query that does not require a database:

$ influx -ssl -username <Username> -password <Password> -host <Endpoint> -port 3242 -execute 'SHOW DATABASES'
name: databases
---------------
name
NOAA_water_database
_internal
telegraf
pirates

Run a query that requires a database and change the timestamp precision:

$ influx -ssl -username <Username> -password <Password> -host <Endpoint> -port 3242 -execute 'SELECT * FROM "h2o_feet" LIMIT 3' -database="NOAA_water_database" -precision=rfc3339
name: h2o_feet
--------------
time                     level description     location      water_level
2015-08-18T00:00:00Z     below 3 feet          santa_monica  2.064
2015-08-18T00:00:00Z     between 6 and 9 feet  coyote_creek  8.12
2015-08-18T00:06:00Z     between 6 and 9 feet  coyote_creek  8.005

Use -format to specify the format of the server responses

The default format is column:

$ influx -ssl -username <Username> -password <Password> -host <Endpoint> -port 3242 -format=column
[...]
> SHOW DATABASES
name: databases
---------------
name
NOAA_water_database
_internal
telegraf
pirates

Change the format to csv:

$ influx -ssl -username <Username> -password <Password> -host <Endpoint> -port 3242 -format=csv
[...]
> SHOW DATABASES
name,name
databases,NOAA_water_database
databases,_internal
databases,telegraf
databases,pirates

Change the format to json:

$ influx -ssl -username <Username> -password <Password> -host <Endpoint> -port 3242 -format=json
[...]
> SHOW DATABASES
{"results":[{"series":[{"name":"databases","columns":["name"],"values":[["NOAA_water_database"],["_internal"],["telegraf"],["pirates"]]}]}]}

Change the format to JSON and enable pretty-printed output:

$ influx -ssl -username <Username> -password <Password> -host <Endpoint> -port 3242 -format=json -pretty
[...]
> SHOW DATABASES
{
    "results": [  
        {
            "series": [
                {
                    "name": "databases",
                    "columns": [
                        "name"
                    ],
                    "values": [
                        [
                            "NOAA_water_database"                       
                        ],
                        [
                            "_internal"
                        ],
                        [
                            "telegraf"
                        ],
                        [
                            "pirates"
                        ]
                    ]
                }
            ]
        }
    ]
}

Use -import to import data from a file

The import file consists of two parts:

Example:

Assume that a database named pirates and a retention policy named oneday are already created.

File (datarrr.txt):

# DML
# CONTEXT-DATABASE: pirates
# CONTEXT-RETENTION-POLICY: oneday
treasures,captain_id=dread_pirate_roberts value=801 1439856000
treasures,captain_id=flint value=29 1439856000
treasures,captain_id=sparrow value=38 1439856000
treasures,captain_id=tetra value=47 1439856000
treasures,captain_id=crunch value=109 1439858880

Command:

$influx -ssl -username <Username> -password <Password> -host <Endpoint> -port 3242 -import -path=datarrr.txt -precision=s

Result:

2015/12/22 12:25:06 Processed 0 commands
2015/12/22 12:25:06 Processed 5 inserts
2015/12/22 12:25:06 Failed 0 inserts

Note

Take note of the following items about -import:

  • Use

    -pps

    to set the number of data points per second that the import allows when data points are written to the database. By default, pps is set to 0 and

    influx

    does not limit the import rate.

  • You can import .gz files. You only need to add

    -compressed

    to the command.

  • Provide timestamps for the data points in the file. TSDB for InfluxDB® assigns the same timestamp to data points that have no timestamps, which may cause unexpected data overwrites.

  • If your data file contains more than 5,000 data points, you may need to split the file into multiple files so that the data can be written to TSDB for InfluxDB® in batches. Write data to TSDB for InfluxDB® in batches of 5,000 or 10,000 data points. Smaller batches generate more HTTP requests, which prevents optimal performance. By default, HTTP requests time out after five seconds. TSDB for InfluxDB® still attempts to write the data points after a timeout, but there is no guarantee that the data points are written.

influx commands

Enter help in the CLI to list some of the available commands.

Commands

The following list briefly describes each command. The insert command is described in detail later in this section.

auth

Prompts you for a username and password. influx requires these credentials when it sends requests to the database. You can also use the INFLUX_USERNAME and INFLUX_PASSWORD environment variables to set the username and password for the CLI.

chunked

Enables chunked responses from the server when a query is issued. This feature is enabled by default.

chunk size <size>

Sets the chunk size of the responses. The default size is 10,000. Setting size to 0 resets the chunk size to the default value.

clear [ database | db | retention policy | rp ]

Clears the current context of the database or retention policy.

connect <host:port>

Connects to another server without exiting the shell. By default, influx connects to localhost:8086. If you do not specify a host or port, influx assumes the default values for the unspecified parameters.

consistency <level>

Sets the write consistency level: any, one, quorum, or all.

Ctrl+C

Interrupts the query that is running. This command is useful when an interactive query does not return results for a long time because it attempts to return too much data.

exit quit Ctrl+D

Exits the influx shell.

format <format>

Specifies the format of the server responses: json, csv, or column.

history

Displays your command history. To use a historical command in the shell, press the Up arrow key. influx stores your last 1,000 commands in the .influx_history file in your home directory.

insert

Writes data by using line protocol.

precision <format>

Specifies the format and precision of the timestamps for queries and writes: rfc3339 (YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ), h (hours), m (minutes), s (seconds), ms (milliseconds), u (microseconds), or ns (nanoseconds). The default precision is nanoseconds.

pretty

Pretty-prints the JSON output for readability.

settings

Displays the current settings of the shell, including Host, Username, Database, Retention Policy, Pretty status, Chunked status, Chunk Size, and Format.

use [ "<database_name>" | "<database_name>"."<retention policy_name>" ]

Sets the current database and/or retention policy. After influx sets a database and/or retention policy, you do not need to specify the database and/or retention policy in queries. If you do not specify a retention policy, influx automatically queries the default (DEFAULT) retention policy of the database.

Use insert to write data to TSDB for InfluxDB®

Enter insert followed by data in line protocol format to write data to TSDB for InfluxDB®. Use insert into <retention policy> <line protocol> to write data to a specific retention policy.

Write data to a single field in the measurement treasures that has the tag captain_id = pirate_king. influx automatically writes the data to the default (DEFAULT) retention policy of the database.

> INSERT treasures,captain_id=pirate_king value=2
>

Write the same data point to the existing retention policy oneday:

> INSERT INTO oneday treasures,captain_id=pirate_king value=2
Using retention policy oneday
>

Query

You can run all InfluxQL queries in influx.

For documentation about InfluxQL, see Overview of data exploration, Schema exploration, and Database management.