description:Instructions and tips for using the TDengine CLI to connect TDengine Cloud
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
The TDengine command-line application (hereafter referred to as `TDengine CLI`) is the most simplest way for users to manipulate and interact with TDengine instances.
## Installation
If executed on the TDengine server-side, there is no need for additional installation steps to install TDengine CLI as it is already included and installed automatically. To run TDengine CLI on the environment which no TDengine server running, the TDengine client installation package needs to be installed first. For details, please refer to [Install Client Driver](/reference/connector/#install-client-driver).
## Config (Linux or Mac)
<TabsdefaultValue="ConfigOnLinux">
<TabItemvalue="ConfigOnLinux"label="Config on Linux">
Run this command in your Linux terminal or Mac terminal to save your URL and token as variables:
Run this command in your Linux terminal to save your URL and token as variables:
```
export TDENGINE_CLOUD_URL=<URL>
export TDENGINE_CLOUD_TOKEN=<token>
```
## Connect (Linux or Mac)
To access the TDengine Cloud, you can execute `taos -R -h $TDENGINE_CLOUD_URL -t $TDENGINE_CLOUD_TOKEN` command-line utility from a Linux terminal, or Mac terminal.
## Config (Windows, WIP, coming soon)
</TabItem>
<TabItemvalue="ConfigOnWindows"label="Config on Windows (work in progress, coming soon)">
Run this command in your Windows terminal to save your URL and token as variables:
...
...
@@ -32,70 +33,44 @@ set TDENGINE_CLOUD_URL=<URL>
set TDENGINE_CLOUD_TOKEN=<token>
```
## Connect (Windows, WIP, coming soon)
</TabItem>
<TabItemvalue="ConfigOnMac"label="Config on Mac (work in progress, coming soon)">
To access the TDengine Cloud, you can execute `taos -R -h %TDENGINE_CLOUD_URL% -t %TDENGINE_CLOUD_TOKEN%` command-line utility from a Windows terminal.
## using TDengine CLI
Run this command in your Mac terminal to save your URL and token as variables:
TDengine CLI will display a welcome message and version information if it successfully connected to the TDengine service. If it fails, TDengine CLI will print an error message. See [FAQ](/train-faq/faq) to solve the problem of terminal connection failure to the server. The TDengine CLI prompts as follows:
```cmd
taos>
```
After entering the TDengine CLI, you can execute various SQL commands, including inserts, queries, or administrative commands.
## Execute SQL script file
Run SQL command script file in the TDengine CLI via the `source` command.
```sql
taos>source<filename>;
export TDENGINE_CLOUD_URL=<URL>
export TDENGINE_CLOUD_TOKEN=<token>
```
## Adjust display width to show more characters
</TabItem>
</Tabs>
Users can adjust the display width in TDengine CLI to show more characters with the following command:
<TabsdefaultValue="ConnectOnLinux">
<TabItemvalue="ConnectOnLinux"label="Connect on Linux">
```sql
taos>SETMAX_BINARY_DISPLAY_WIDTH<nn>;
```
To access the TDengine Cloud, you can execute `taos -R -h $TDENGINE_CLOUD_URL -t $TDENGINE_CLOUD_TOKEN` command-line utility from a Linux terminal.
If the displayed content is followed by `...` you can use this command to change the display width to display the full content.
</TabItem>
<TabItemvalue="ConnectOnWindows"label="Connect on Windows (work in progress, coming soon)">
## Command Line Parameters
To access the TDengine Cloud, you can execute `taos -R -h %TDENGINE_CLOUD_URL% -t %TDENGINE_CLOUD_TOKEN%` command-line utility from a Windows terminal.
You can change the behavior of TDengine CLI by specifying command-line parameters. The following parameters are commonly used.
</TabItem>
<TabItemvalue="ConnectOnMac"label="Connect on Mac">
- -R, --restful: The flag to use REST interface to access TDengine Cloud.
- -h, --host=CLOUD_HOST: specify the host url the TDengine Cloud assign for the registered user to access the cloud.
- -t, --token=CLOUD_TOKEN: specify the token the TDengine Cloud assign for the registered user to access the cloud.
- -?, --help: print out all command-line arguments
To access the TDengine Cloud, you can execute `taos -R -h $TDENGINE_CLOUD_URL -t $TDENGINE_CLOUD_TOKEN` command-line utility from a Mac terminal.
And many more parameters.
</TabItem>
</Tabs>
- -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
- -r, --raw-time: output the timestamp format as unsigned 64-bits integer (uint64_t in C language)
- -s, --commands=COMMAND: execute SQL commands in non-interactive mode
- -T, --thread=THREADNUM: The number of threads to import data in multi-threaded mode
- -s, --commands: Run TDengine CLI commands without entering the terminal
- -z, --timezone=TIMEZONE: Specify time zone. Default is the value of current configuration file
- -V, --version: Print out the current version number
## using TDengine CLI
Example.
TDengine CLI will display a welcome message and version information if it successfully connected to the TDengine service. If it fails, TDengine CLI will print an error message. See [FAQ](/train-faq/faq) to solve the problem of terminal connection failure to the server. The TDengine CLI prompts as follows:
```bash
taos-R-h$CLOUD_HOST-t$CLOUD_TOKEN-s"use db; show tables;"
```cmd
taos>
```
## TDengine CLI tips
After entering the TDengine CLI, you can execute various SQL commands, including inserts, queries, or administrative commands. Please see the [official document](https://docs.tdengine.com/reference/taos-shell#execute-sql-script-file) for more details.
- You can use the up and down keys to iterate the history of commands entered
- Change user password: use `alter user` command in TDengine CLI to change user's password. The default password is `taosdata`.
- use 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 command) in a script file and execute the command `source <file-name>` in the TDengine CLI to execute all SQL commands in that file automatically
@@ -7,13 +7,6 @@ TDengine can be quickly integrated with the open-source data visualization syste
You can learn more about using the TDengine plugin on [GitHub](https://github.com/taosdata/grafanaplugin/blob/master/README.md).
## Prerequisites
In order for Grafana to add the TDengine data source successfully, the following preparations are required:
1. The TDengine cluster is deployed and functioning properly
2. taosAdapter is installed and running properly. Please refer to the taosAdapter manual for details.
## Installing Grafana
TDengine currently supports Grafana versions 7.5 and above. Users can go to the Grafana official website to download the installation package and execute the installation according to the current operating system. The download address is as follows: <https://grafana.com/grafana/download>.
...
...
@@ -75,25 +68,4 @@ Click `Save & Test` to test. You should see a success message if the test worked
As shown above, select the `TDengine` data source in the `Query` and enter the corresponding SQL in the query box below for query.
- INPUT SQL: enter the statement to be queried (the result set of the SQL statement should be two columns and multiple rows), for example: `select avg(mem_system) from log.dn where ts >= $from and ts < $to interval($interval)`, where, from, to and interval are built-in variables of the TDengine plugin, indicating the range and time interval of queries fetched from the Grafana plugin panel. In addition to the built-in variables, custom template variables are also supported.
- ALIAS BY: This allows you to set the current query alias.
- GENERATE SQL: Clicking this button will automatically replace the corresponding variables and generate the final executed statement.
Follow the default prompt to query the average system memory usage for the specified interval on the server where the current TDengine deployment is located as follows.
> For more information on how to use Grafana to create the appropriate monitoring interface and for more details on using Grafana, refer to the official Grafana [documentation](https://grafana.com/docs/).
### Importing the Dashboard
In version 2.3.3.0 and above, you can import the TDinsight Dashboard (Grafana Dashboard ID: [15167](https://grafana.com/grafana/dashboards/15167)) as a monitoring visualization tool for TDengine clusters. You can find installation and usage instructions in the TDinsight User Manual (/reference/tdinsight/).
Please refer to the [documentation](https://docs.tdengine.com/third-party/grafana#create-dashboard) for more details.