All Products
Search
Document Center

Lindorm:Use Lindorm-cli to connect to and use LindormTable

Last Updated:Sep 21, 2023

This topic describes how to use Lindorm-cli to connect to and use LindormTable.

Prerequisites

The endpoint that is used to connect to LindormTable SQL is obtained. The IP address used to access LindormTable SQL is added to the whitelist of the Lindorm instance. For more information, see Connect to a Lindorm instance.

Types of networks used 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. 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 View endpoints.

Common commands

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

  1. Download an installation package of Lindorm-cli. You can download a compressed Lindorm-cli package based on the operating system of your client.

    Operating system

    Download link

    Linux

    lindorm-cli for linux

    Mac

    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.

  3. Obtain required connection information and connect to LindormTable.

    • If your client is deployed in Linux or macOS, use the following method to connect to LindormTable.

      Run the following commands to go to the path in which lindorm-cli is located and then connect to LindormTable:

      cd <Path of lindorm-cli>
      ./lindorm-cli -url <jdbc url> -username <Username> -password <Password>
    • If your client is deployed in Windows, you can use one of the following methods to connect to LindormTable:

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

      • Run the following commands to go to the path in which lindorm-cli.exe is located and connect to LindormTable:

        cd <Path of lindorm-cli>
        lindorm-cli -url <jdbc url> -username <Username> -password <Password>

        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.

    The following table describes the parameters

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

    Important

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

    Password

    test

  5. Access a Lindorm wide table. The following examples show the syntaxes that you can use to access a Lindorm wide table:

    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; 
    3. Create a table named tb in the test database and insert a row of data into the tb table.

      create table tb (id varchar, name varchar, address varchar,  primary key(id, name)) ; 
      upsert into tb (id, name, address) values ('001', 'jack',  'hz'); 
    4. Query data in the tb table.

      select * from tb;

      The following result is returned:

      +-----+-------+---------+
      | id  | name  | address |
      +-----+-------+---------+
      | 001 | jack  | hz      |
      +-----+-------+---------+
      1 rows in set (24 ms)
      Note

      You can configure the format of the returned data. For more information, see Format of returned data.

Format of returned data

Returned data can be output in various formats, such as a table, a CSV file, or vertical columns. By default, data is returned as a table. 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.

Important

The format command is supported only in Lindorm-cli.

Specify to output returned data as a table

format table;
select * from tb;

Example:

+-----+-------+---------+
| id  | name  | address |
+-----+-------+---------+
| 001 | jack  | hz      |
+-----+-------+---------+
1 rows in set (99 ms)

Specify to output returned data as a CSV file

format csv;
select * from tb;

Example:

id,name,address
001,jack,hz

Specify to output returned data as vertical columns

format vertical;
select * from tb;

Example:

********************* 1. row *********************
id:      001
name:    jack
address: hz
1 rows in set (99 ms)