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 a whitelist.
Types of networks used to connect to LindormTable
Endpoint 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. For more information, see What is ECS? |
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
|
Common commands used in Lindorm-cli
For more information about the SQL syntax supported by LindormTable, see LindormTable SQL.
!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.
Procedure
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
Mac
Windows
Linux-arm64
Decompress the installation package of Lindorm-cli.
Run the following command to decompress the downloaded Lindorm-cli client package.
tar zxvf lindorm-cli-linux-latest.tar.gz
The executable file
lindorm-cli.exe
is located in thelindorm-cli-linux-latest
directory.
Step 2: Connect to LindormTable
Clients deployed in Linux or macOS
Run the following command to go to the path in which
lindorm-cli.exe
is located:cd <Path of lindorm-cli.exe>
Run the following command to connect to LindormTable:
./lindorm-cli -url <jdbc url> -username <Username> -password <Password>
Parameters
Parameter
Example
Method used to obtain the parameter value
jdbc url
jdbc:lindorm:table:url=http://ld-bp17j28j2y7pm****-proxy-lindorm-pub.lindorm.rds.aliyuncs.com:30060
The endpoint that is required when you use SQL to connect to and use LindormTable. For more information about how to obtain the endpoint, see Connect to a Lindorm instance.
Username
user
The username and password that are used to access LindormTable. If you forget your password, you can go to the cluster management system of LindormTable to reset the password. For more information, see Change the password of a user.
ImportantAfter you change your password, you must restart LindormTable in the Lindorm console.
Password
test
If the client is connected to LindormTable, the following result is returned:
lindorm-cli version: 1.0.xx
In the result,
1.0.xx
indicates the version of Lindorm-cli.
Clients deployed in Windows
Method 1
Run the following command in 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 Command Prompt to connect to LindormTable:
lindorm-cli -url <jdbc url> -username <Username> -password <Password>
Parameters
Parameter
Example
Method used to obtain the parameter value
jdbc url
jdbc:lindorm:table:url=http://ld-bp17j28j2y7pm****-proxy-lindorm-pub.lindorm.rds.aliyuncs.com:30060
The endpoint that is required when you use SQL to connect to and use LindormTable. For more information about how to obtain the endpoint, see Connect to a Lindorm instance.
Username
user
The username and password that are used to access LindormTable. If you forget your password, you can go to the cluster management system of LindormTable to reset the password. For more information, see Change the password of a user.
ImportantAfter you change your password, you must restart LindormTable in the Lindorm console.
Password
test
The following result is returned if the client is connected to LindormTable:
Connected to jdbc:lindorm:table:url=http://ld-bp17j28j2y7pm****-proxy-lindorm-pub.lindorm.rds.aliyuncs.com:30060 lindorm-cli version: 1.0.xx
In the result,
1.0.xx
indicates the version of Lindorm-cli.
Method 2
Double click lindorm-cli.exe to open the client and run the following command:
connect <jdbc url> <Username> <Password>
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
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