Skip to main content

Databend CLI Reference

bendctl is a command-line tool for creating, listing, logging, deleting databend running instances on local or on cloud. It also supports to port forward webUI, monitoring dashboard on local and run SQL queries from command line.

1. Install

curl -fsS https://repo.databend.rs/databend/install-bendctl.sh | bash
export PATH="${HOME}/.databend/bin:${PATH}"

2. Help

$ bendctl
[local] [sql]> help
[ok] โœ… Mode switch commands:
\sql Switch to query mode, you could run query directly under this mode
\admin Switch to cluster administration mode, you could profile/view/update databend cluster
[ok] โœ… Admin commands:
+---------+-------------------------------------------+
| Name | About |
+---------+-------------------------------------------+
| version | Databend CLI version |
| package | Package command |
| cluster | Cluster life cycle management |
| up | Bootstrap a single cluster with dashboard |
+---------+-------------------------------------------+

3. Setting up a cluster

[local] [sql]> \admin
Mode switched to admin mode
[local] [admin]> cluster create
[ok] โœ… Databend cluster pre-check passed!
[ok] โœ… Successfully started meta service with rpc endpoint 127.0.0.1:9191
[ok] โœ… Local data would be stored in /home/bohu/.databend/local/data
[ok] โœ… Successfully started query service.
[ok] โœ… To run queries through bendctl, run: bendctl query 'your SQL'
[ok] โœ… For example: bendctl query 'SELECT sum(number), avg(number) FROM numbers(100)'
[ok] โœ… To process mysql queries, run: mysql -h127.0.0.1 -P3307 -uroot
[ok] โœ… To process clickhouse queries, run: clickhouse client --host 127.0.0.1 --port 9000 --user root
[ok] โœ… To process HTTP REST queries, run: curl --location --request POST '127.0.0.1:24974/v1/statement/' --header 'Content-Type: text/plain' --data-raw 'your SQL'
[local] [admin]>

4. Query Example

note

numbers(N) โ€“ A table for test with the single number column (UInt64) that contains integers from 0 to N-1.

[local] [admin]> \sql
Mode switched to SQL query mode
[local] [sql]> SELECT avg(number) FROM numbers(1000000000);
+-------------+
| avg(number) |
+-------------+
| 499999999.5 |
+-------------+
[ok] read rows: 1,000,000,000, read bytes: 8.00 GB, rows/sec: 1,259,445,843 (rows/sec), bytes/sec: 10.07556675 (GB/sec)
[local] [sql]>

5. Stop a cluster

[local] [admin]> cluster stop
[ok] โš  Start to clean up local services
[ok] โš  Stopped query service with config in /home/bohu/.databend/local/configs/local/query_config_0.yaml
[ok] โš  Stopped meta service with config in /home/bohu/.databend/local/configs/local/meta_config_0.yaml
[ok] ๐Ÿš€ Stopped all services
[local] [admin]>

6. Demo

bendctl on AWS arm64-server