Lindorm-cli is a simple command-line tool that is used to connect to and manage Lindorm databases. You can use Lindorm-cli to perform basic SQL operations, such as table creation, data query, data writing, and data export. This topic describes how to use Lindorm-cli to connect to and use the Lindorm wide table engine (LindormTable).
Prerequisites
The IP address of your client is added to the whitelist of the Lindorm instance. For more information, see Configure whitelists.
Network types
You can use the following network types to connect to LindormTable.
Network type | Description |
VPC (recommended) | A VPC is a private network dedicated to your Alibaba Cloud account. VPCs are logically isolated from each other to provide high security. When Lindorm-cli is deployed on your Elastic Compute Service (ECS) instance, you can use Lindorm-cli to connect to LindormTable over a VPC. This ensures high security and reduces network latency. |
Internet | If you want to use an on-premises device to test or manage LindormTable, you can deploy Lindorm-cli on the device and connect the device to LindormTable over the Internet. Note
|
Use the MySQL protocol to connect to LindormTable (recommended)
Step 1: Install Lindorm-cli
Download a Lindorm-cli client package based on the operating system of your client. The following table provides the download links of Lindorm-cli client packages for different operating systems.
Operating system
Download link
Linux
You can also download it directly by running the command:
wget https://tsdbtools.oss-cn-hangzhou.aliyuncs.com/lindorm-cli-linux-latest.tar.gz
.Linux-arm64
You can also download it directly by running the command:
wget https://tsdbtools.oss-cn-hangzhou.aliyuncs.com/lindorm-cli-linux-arm64-latest.tar.gz
.Mac (Intel chip)
Mac (Arm chip)
Windows
Decompress the installation package of Lindorm-cli.
Run the following command to decompress the downloaded Lindorm-cli client package. Then, you can obtain the
lindorm-cli
file.tar zxvf lindorm-cli-linux-latest.tar.gz
Step 2: Connect to LindormTable
This feature is supported only by Lindorm-cli 2.0.0 or later.
Clients deployed on Linux or macOS
Run the following command to go to the path in which
Lindorm-cli
is located:cd <Path of Lindorm-cli>
Run the following command to connect to LindormTable:
./lindorm-cli -url <mysql url> -username <Username> -password <Password>
Parameters
Parameter
Description
mysql url
The LindormTable endpoint for MySQL. For more information about connection configurations, see Connection settings.
Username
The username used to connect to LindormTable.
Password
The password used to connect to LindormTable.
ImportantIf you forget your password, you can go to the cluster management system of LindormTable to change the password.
After you change your password, you must restart LindormTable in the Lindorm console.
Connection settings
Supported connection setting
Description
mysql://
protocol headerYou can add the
mysql://
protocol header before the LindormTable endpoint for MySQL.Example:
mysql://ld-8vbn68478unu8****-proxy-sql-lindorm.lindorm.rds.aliyuncs.com:33060
.Custom parameter on the server side
You can configure a server-side parameter in the
key1=value1&key2=value2
format after the LindormTable endpoint for MySQL.Currently, you can configure only the
operationTimeout
parameter, which specifies the query timeout duration in milliseconds.Format:
<Endpoint for MySQL>?operationTimeout=<Timeout duration>
.Example:
ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060?operationTimeout=120000
.ImportantThe
operationTimeout
parameter can be configured only in LindormTable 2.7.7 or later. For more information about how to view or upgrade the version, see Release notes of LindormTable and Upgrade the minor engine version of a Lindorm instance.Example
./lindorm-cli -url ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060 -username user -password test --Add the mysql:// protocol header. ./lindorm-cli -url mysql://ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060 -username user -password test --Specify the query timeout duration. ./lindorm-cli -url mysql://ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060?operationTimeout=120000 -username user -password test
If the client is connected to LindormTable, the following result is returned:
lindorm-cli version: 2.0.x
In the result,
2.0.x
indicates the version of Lindorm-cli.
Clients deployed on Windows
Method 1
Run the following command in the command prompt to go to the path in which
lindorm-cli.exe
is located:cd <Path of lindorm-cli.exe>
Run the following command in the command prompt to connect to LindormTable:
lindorm-cli -url <mysql url> -username <Username> -password <Password>
Parameters
Parameter
Example
Method used to obtain the parameter value
mysql url
ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060
The LindormTable endpoint for MySQL. For more information about connection configurations, see Connection settings.
Username
user
The username used to connect to LindormTable.
Password
test
The password used to connect to LindormTable.
ImportantIf you forget your password, you can go to the cluster management system of LindormTable to change the password.
After you change your password, you must restart LindormTable in the Lindorm console.
Connection settings
Supported connection setting
Description
mysql://
protocol headerYou can add the
mysql://
protocol header before the LindormTable endpoint for MySQL.Example:
mysql://ld-8vbn68478unu8****-proxy-sql-lindorm.lindorm.rds.aliyuncs.com:33060
.Custom connection parameters on the server side
You can configure a server-side parameter in the
key1=value1&key2=value2
format after the LindormTable endpoint for MySQL.Currently, you can configure only the
operationTimeout
parameter, which specifies the query timeout duration in milliseconds.Format:
<Endpoint for MySQL>?operationTimeout=<Timeout duration>
.Example:
ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060?operationTimeout=120000
.ImportantThe
operationTimeout
parameter can be configured only in LindormTable 2.7.7 or later. For more information about how to view or upgrade the version, see Release notes of LindormTable and Upgrade the minor engine version of a Lindorm instance.Example
lindorm-cli -url ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060 -username user -password test --Add the mysql:// protocol header. lindorm-cli -url mysql://ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060 -username user -password test --Specify the query timeout duration. lindorm-cli -url mysql://ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060?operationTimeout=120000 -username user -password test
If the client is connected to LindormTable, the following result is returned:
Connected to ld-bp187uwcx5f40****-proxy-sql-lindorm-public.lindorm.rds.aliyuncs.com:33060 lindorm-cli version: 2.0.x
In the result,
2.0.x
indicates the version of Lindorm-cli.
Method 2
Double-click lindorm-cli.exe to open the client and run the following command:
connect <mysql url> <Username> <Password>
Example
connect ld-bp13y790c91f4****-proxy-lindorm-pub.lindorm.aliyuncs.com:33060 user test
No result is returned if the client is connected to LindormTable.
Step 3: Use LindormTable to perform operations
Create a database
Execute the following statement to create a database named
test
:CREATE DATABASE test;
Execute the following statement to use the
test
database:USE test;
Create a table
Create a table named tb
in the test
database.
CREATE TABLE tb (id VARCHAR, name VARCHAR, address VARCHAR, PRIMARY KEY(id, name)) ;
Write data to LindormTable
UPSERT INTO tb (id, name, address) VALUES ('001', 'jack', 'hz');
Query data in LindormTable
Returned data can be output in various formats, such as a table, a CSV file, or vertical columns. You can use the format
command to specify the format of the returned data. Data queried by SELECT
statements is returned in the specified format. By default, data is returned as a table.
The format
command is supported only in Lindorm-cli.
Specify to output returned data as a table (default)
Execute the following query statement:
format table;
SELECT * FROM tb;
The query statement is equivalent to the following statement:
SELECT * FROM tb;
The following result is returned:
+-----+-------+---------+
| id | name | address |
+-----+-------+---------+
| 001 | jack | hz |
+-----+-------+---------+
Specify to output returned data as a CSV file
format csv;
SELECT * FROM tb;
The following result is returned:
id,name,address
001,jack,hz
Specify to output returned data as vertical columns
format vertical;
SELECT * FROM tb;
The following result is returned:
********************* 1. row *********************
id: 001
name: jack
address: hz
Use the Avatica protocol to connect to LindormTable
Step 1: Install Lindorm-cli
Step 2: Connect to LindormTable
Step 3: Use LindormTable to perform operations
Common commands used in Lindorm-cli
!help: You can run this command to view help information.
!connect: You can run this command to connect to a server.
exit, quit, and ctrl+d: You can run one of these commands to exit the current connection.
FAQ
Why does the connection time out or fail?
When a connection times out or fails, the Failed to connect to <LindormTable endpoint> connection check failed
or connection timeout
error message is displayed.
The following table describes the possible causes and solutions.
Cause | Solution |
You are connecting to LindormTable over the Internet, but the public IP address is not added to the whitelist. | Add the public IP address of the client to the Lindorm whitelist. You can use one of the following methods to query the public IP address of the client:
|
The public IP address is added to the whitelist, but the connection still times out. | This may be caused by network instability. We recommend that you connect to LindormTable over a VPC. |
You are using an ECS instance to connect to LindormTable, but the IP address of the ECS instance is not added to the Lindorm whitelist. | Obtain the IP address of the ECS instance and add it to the Lindorm whitelist. |
The endpoint is invalid. | Lindorm provides private and public endpoints. Use the correct endpoint based on your network environment. |
If the preceding solutions do not resolve your issue, contact Lindorm technical support (DingTalk ID: s0s3eg3).
References
For more information about the SQL syntax supported by LindormTable, see SQL reference.
For more information about other connection methods, see Use a MySQL client to connect to and use LindormTable and Use the MySQL protocol to develop applications (recommended).