Command Line Interface(CLI)

IoTDB provides Cli/shell tools for users to interact with IoTDB server in command lines. This document will show how Cli/shell tool works and what does it parameters mean.

Note: In this document, $IOTDB_HOME represents the path of the IoTDB installation directory.

Build client from source code

Under the root path of incubator-iotdb:

  1. > mvn clean package -pl client -am -DskipTests

After build, the IoTDB client will be at the folder “client/target/iotdb-client-{project.version}”.

Running Cli/Shell

After installation, there is a default user in IoTDB: root, and the default password is root. Users can use this username to try IoTDB Cli/Shell tool. The client startup script is the start-client file under the $IOTDB_HOME/bin folder. When starting the script, you need to specify the IP and PORT. (Make sure the IoTDB server is running properly when you use Cli/Shell tool to connect it.)

Here is an example where the server is started locally and the user has not changed the running port. The default port is 6667
If you need to connect to the remote server or changes the port number of the server running, set the specific IP and PORT at -h and -p.
You also can set your own environment variable at the front of the start script (“/sbin/start-client.sh” for linux and “/sbin/start-client.bat” for windows)

The Linux and MacOS system startup commands are as follows:

  1. Shell > ./sbin/start-client.sh -h 127.0.0.1 -p 6667 -u root -pw root

The Windows system startup commands are as follows:

  1. Shell > \sbin\start-client.bat -h 127.0.0.1 -p 6667 -u root -pw root

After using these commands, the client can be started successfully. The successful status will be as follows:

  1. _____ _________ ______ ______
  2. |_ _| | _ _ ||_ _ `.|_ _ \
  3. | | .--.|_/ | | \_| | | `. \ | |_) |
  4. | | / .'`\ \ | | | | | | | __'.
  5. _| |_| \__. | _| |_ _| |_.' /_| |__) |
  6. |_____|'.__.' |_____| |______.'|_______/ version <version>
  7. IoTDB> login successfully
  8. IoTDB>

Enter quit or exit can exit Client. The client will shows quit normally

Cli/Shell Parameters

Parameter nameParameter typeRequiredDescriptionExample
-disableIS08601No parametersNoIf this parameter is set, IoTDB will print the timestamp in digital form-disableIS08601
-h <host>string, no quotation marksYesThe IP address of the IoTDB server-h 10.129.187.21
-helpNo parametersNoPrint help information for IoTDB-help
-p <port>intYesThe port number of the IoTDB server. IoTDB runs on port 6667 by default-p 6667
-pw <password>string, no quotation marksNoThe password used for IoTDB to connect to the server. If no password is entered, IoTDB will ask for password in Cli command-pw root
-u <username>string, no quotation marksYesUser name used for IoTDB to connect the server-u root
-maxPRC <maxPrintRowCount>intNoSet the maximum number of rows that IoTDB returns-maxPRC 10
-e <execute>stringNomanipulate IoTDB in batches without entering client input mode-e “show storage group”

Following is a client command which connects the host with IP 10.129.187.21, port 6667, username “root”, password “root”, and prints the timestamp in digital form. The maximum number of lines displayed on the IoTDB command line is 10.

The Linux and MacOS system startup commands are as follows:

  1. Shell > ./sbin/start-client.sh -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10

The Windows system startup commands are as follows:

  1. Shell > \sbin\start-client.bat -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10

Cli/shell tool with -e parameter

-e parameter is designed for the Cli/shell tool in the situation where you would like to manipulate IoTDB in batches through scripts. By using the -e parameter, you can operate IoTDB without entering the client’s input mode.

In order to avoid confusion between statements and other parameters, the current situation only supports the -e parameter as the last parameter.

The usage of -e parameter for Cli/shell is as follows:

  1. Shell > ./sbin/start-client.sh -h {host} -p {port} -u {user} -pw {password} -e {sql for iotdb}

In order to better explain the use of -e parameter, take following as an example.

Suppose you want to create a storage group root.demo to a newly launched IoTDB, create a timeseries root.demo.s1 and insert three data points into it. With -e parameter, you could write a shell like this:

  1. # !/bin/bash
  2. host=127.0.0.1
  3. port=6667
  4. user=root
  5. pass=root
  6. ./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "set storage group to root.demo"
  7. ./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "create timeseries root.demo.s1 WITH DATATYPE=INT32, ENCODING=RLE"
  8. ./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(1,10)"
  9. ./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(2,11)"
  10. ./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(3,12)"
  11. ./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "select s1 from root.demo"

The print results are shown in the figure, which are consistent with the client and jdbc operations.

img

It should be noted that the use of the -e parameter in shell scripts requires attention to the escaping of special characters.