08-taos-shell.md 4.1 KB
Newer Older
D
dingbo 已提交
1
---
2
title: TDengine Command Line (CLI)
D
dingbo 已提交
3
sidebar_label: TDengine CLI
4
description: Instructions and tips for using the TDengine CLI
D
dingbo 已提交
5 6
---

7
The TDengine command-line application (hereafter referred to as TDengine CLI) is the cleanest and most common way for users to manipulate and interact with TDengine instances.
D
dingbo 已提交
8

9
## Installation
D
dingbo 已提交
10

11
If executed on the TDengine server-side, there is no need for additional installation as it is already installed automatically. To run on the non-TDengine server-side, the TDengine client driver needs to be installed. For details, please refer to [connector](/reference/connector/).
D
dingbo 已提交
12

13
## Execution
D
dingbo 已提交
14

15
To access the TDengine CLI, you can execute `taos` from a Linux terminal or Windows terminal.
D
dingbo 已提交
16 17 18 19

```bash
taos
```
20
TDengine will display a welcome message and version information if the connection to the service is successful. If it fails, TDengine will print an error message (see [FAQ](/train-faq/faq) to solve the problem of terminal connection failure to the server.) The TDengine CLI prompt symbols are as follows:
D
dingbo 已提交
21 22 23 24

```cmd
taos>
```
25
After entering the CLI, you can execute various SQL statements, including inserts, queries, and administrative commands.
D
dingbo 已提交
26

27
## Execute SQL scripts
D
dingbo 已提交
28

29
Run SQL command scripts in the TDengine CLI via the `source` command.
D
dingbo 已提交
30 31 32 33 34

```sql
taos> source <filename>;
```

35
## Modify display character width online
D
dingbo 已提交
36

37
Users can adjust the character display width in TDengine CLI with the following command:
D
dingbo 已提交
38 39 40 41 42

```sql
taos> SET MAX_BINARY_DISPLAY_WIDTH <nn>;
```

43
If the displayed content is followed by `...` you can use this command to change the display width to display the full content.
D
dingbo 已提交
44

45
## Command Line Parameters
D
dingbo 已提交
46

47
You can change the behavior of TDengine CLI by configuring command-line parameters. The following command-line arguments are commonly used.
D
dingbo 已提交
48

49 50 51 52 53
-h, --host=HOST: FQDN of the server where the TDengine server is to be connected. Default is to connect to the local service
-P, --port=PORT: Specify the port number to be used by the server
-u, --user=USER: the user name to use when connecting
-p, --password=PASSWORD: the password to use when connecting to the server
--?, --help: print out all command-line arguments 
D
dingbo 已提交
54

55
And many more parameters.
D
dingbo 已提交
56

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
-c, --config-dir: Specify the configuration file directory. The default is `/etc/taos`, and the default name of the configuration file in this directory is taos.cfg
-C, --dump-config: Print the configuration parameters of taos.cfg in the directory specified by -c
-d, --database=DATABASE: Specify the database to use when connecting to the server
-D, --directory=DIRECTORY: Import the SQL script file in the specified path
-f, --file=FILE: Execute the SQL script file in non-interactive mode
-k, --check=CHECK: Specify the table to be checked
-l, --pktlen=PKTLEN: Test package size to be used for network testing
-n, --netrole=NETROLE: test scope for network connection test, default is `startup`, The value can be `client`, `server`, `rpc`, `startup`, `sync`, `speed`, or `fqdn`.
-r, --raw-time: output the time to uint64_t
-s, --commands=COMMAND: execute SQL commands in non-interactive mode
-S, --pkttype=PKTTYPE: Specify the packet type used for network testing. The default is TCP. only `netrole` can be specified as either TCP or UDP when speed is specified
-T, --thread=THREADNUM: The number of threads to import data in multi-threaded mode
-s, --commands: Run TDengine commands without entering the terminal
-z, --timezone=TIMEZONE: Specify time zone. Default is local
-V, --version: Print out the current version number
D
dingbo 已提交
72

73
Example.
D
dingbo 已提交
74 75 76 77

```bash
taos -h h1.taos.com -s "use db; show tables;"
```
78 79 80 81 82 83 84 85
## TDengine CLI tips

- You can use the up and down cursor keys to see the history of commands entered
- Change user password: use `alter user` command in TDengine CLI. The default password is `taosdata`.
- ctrl+c to stop a query in progress
- Execute `RESET QUERY CACHE` to clear the local cache of the table schema
- Execute SQL statements in batches. You can store a series of shell commands (ending with ;, one line for each SQL statement) in a file and execute the command `source <file-name>` in the shell to execute all SQL statements in that file automatically
- Enter `q` to exit taos shell