Command Line Interface(CLI)
- Command Line Interface(CLI)
- Running Cli/Shell
- Cli/Shell Parameters
- Cli/shell tool with -e parameter
Under the root path of incubator-iotdb:
After build, the IoTDB cli will be at the folder “cli/target/iotdb-cli-{project.version}”.
After installation, there is a default user in IoTDB: , and the default password is root
. Users can use this username to try IoTDB Cli/Shell tool. The cli startup script is the start-cli
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-cli.sh” for linux and “/sbin/start-cli.bat” for windows)
The Linux and MacOS system startup commands are as follows:
Shell > sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
The Windows system startup commands are as follows:
Shell > sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
After using these commands, the cli can be started successfully. The successful status will be as follows:
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | / .'`\ \ | | | | | | | __'.
_| |_| \__. | _| |_ _| |_.' /_| |__) |
|_____|'.__.' |_____| |______.'|_______/ version <version>
IoTDB> login successfully
IoTDB>
Following is a cli 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:
The Windows system startup commands are as follows:
Shell > sbin\start-cli.bat -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
If OIDC is enabled on server side then no username / passwort is needed but a valid Access Token from the OIDC Provider. So as username you use the token and the password has to be empty, e.g.
Shell > sbin/start-cli.sh -h 10.129.187.21 -p 6667 -u {my-access-token} -pw ""
How to get the token is dependent on your OpenID Connect setup and not covered here. In the simplest case you can get this via the command line with the passwort-grant
. For example, if you use keycloack as OIDC and you have a realm with a client iotdb
defined as public you could use the following curl
command to fetch a token (replace all {}
with appropriate values).
curl -X POST "https://{your-keycloack-server}/auth/realms/{your-realm}/protocol/openid-connect/token" \ ✔ 1613 11:09:38
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username={username}" \
-d "password={password}" \
-d 'grant_type=password' \
The response looks something like
The interesting part here is the access token with the key . This has to be passed as username (with parameter -u
) and empty password to the CLI.
-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 cli’s input mode.
The usage of -e parameter for Cli/shell is as follows:
The Linux and MacOS system commands:
Shell > sbin/start-cli.sh -h {host} -p {port} -u {user} -pw {password} -e {sql for iotdb}
The Windows system commands:
Shell > sbin\start-cli.bat -h {host} -p {port} -u {user} -pw {password} -e {sql for iotdb}
In the Windows environment, the SQL statement of the -e parameter needs to use ``
to replace " "
In order to better explain the use of -e parameter, take following as an example(On linux system).
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:
# !/bin/bash
host=127.0.0.1
port=6667
user=root
pass=root
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "set storage group to root.demo"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "create timeseries root.demo.s1 WITH DATATYPE=INT32, ENCODING=RLE"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(1,10)"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(2,11)"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(3,12)"
The print results are shown in the figure, which are consistent with the cli and jdbc operations.