Use Lindorm-cli to connect to and use LindormTable

Updated at: 2025-01-23 02:55

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.

Types of networks used to connect to LindormTable

Endpoint network type

Description

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
  • You are not charged for traffic that is generated when you access LindormTable over the Internet. However, the connection may be exposed to security risks. We recommend that you use a VPC to connect to LindormTable to ensure security.

  • To use the public endpoint to connect to LindormTable, enable the public endpoint in the Lindorm console. For more information, see the Procedure section of the "View endpoint" chapter.

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

  1. 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

    Operating system

    Download link

    Linux

    lindorm-cli for linux

    Mac (Intel chip)

    lindorm-cli for mac

    Mac (Arm chip)

    lindorm-cli for mac

    Windows

    lindorm-cli for windows-x64

    Linux-arm64

    lindorm-cli for linux-arm64

  2. 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 the lindorm-cli-linux-latest directory.

Step 2: Connect to LindormTable

Use the MySQL protocol to connect to LindormTable

Important

This feature is supported only by Lindorm-cli 2.0.0 or later.

Clients deployed on Linux or macOS
Clients deployed on Windows
  1. Run the following command to go to the path in which Lindorm-cli is located:

    cd <Path of Lindorm-cli>
  2. Run the following command 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 how to obtain the endpoint, see Connect to LindormTable. For more information about connection configurations, see Connection settings.

    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.

    Important

    After you reset your password, you must restart LindormTable in the Lindorm console.

    Password

    test

    Connection settings

    • When you use the LindormTable endpoint for MySQL to connect to LindormTable, add the mysql:// protocol header before the endpoint. Example: mysql://ld-8vbn68478unu8****-proxy-sql-lindorm.lindorm.rds.aliyuncs.com:33060.

    • You can configure a parameter on the server side by using the key1=value1&key2=value2 format. Currently, you can configure only the operationTimeout parameter, which specifies the query timeout duration in milliseconds. Format: <mysql url>?operationTimeout=<timeout duration>. Example: ld-bp187uwcx5f40****-proxy-lindorm-vpc.lindorm.aliyuncs.com:33060?operationTimeout=120.

      Important

      The 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.

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.

Method 1

  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>
  2. 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 how to obtain the endpoint, see Connect to LindormTable. For more information about connection configurations, see Connection settings.

    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.

    Important

    After you reset your password, you must restart LindormTable in the Lindorm console.

    Password

    test

    If the client is connected to LindormTable, the following result is returned:

    Connected to ld-bp173e6a9sr18****-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>

No result is returned if the client is connected to LindormTable.

Use the Avatica protocol to connect to LindormTable

Clients deployed on Linux or macOS
Clients deployed on Windows
  1. Run the following command to go to the path in which Lindorm-cli.exe is located:

    cd <Path of Lindorm-cli.exe>
  2. Run the following command to connect to LindormTable:

    ./lindorm-cli -url <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 LindormTable.

    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.

    Important

    After you reset 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.

Method 1

  1. Run the following command in the command prompt to go to the path in which lindorm-cli is located:

    cd <Path of lindorm-cli>
  2. Run the following command in the 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 LindormTable.

    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.

    Important

    After you reset 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

  1. Execute the following statement to create a database named test:

    CREATE DATABASE test; 
  2. 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.

Important

The format command is supported only in Lindorm-cli.

Specify to output returned data as a table
Specify to output returned data as a CSV file
Specify to output returned data as vertical columns

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      |
+-----+-------+---------+
format csv;
SELECT * FROM tb;

The following result is returned:

id,name,address
001,jack,hz
format vertical;
SELECT * FROM tb;

The following result is returned:

********************* 1. row *********************
id:      001
name:    jack
address: hz
  • On this page (1)
  • Prerequisites
  • Types of networks used to connect to LindormTable
  • Common commands used in Lindorm-cli
  • Procedure
  • Step 1: Install Lindorm-cli
  • Step 2: Connect to LindormTable
  • Step 3: Use LindormTable to perform operations
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare