You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/guides/30-sql-clients/00-bendsql/index.md
+92Lines changed: 92 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,6 +147,98 @@ If you are connecting to a self-hosted Databend instance, you can use the admin
147
147
148
148
For connections to Databend Cloud, you can use the default `cloudapp` user or an SQL user created with the [CREATE USER](/sql/sql-commands/ddl/user/user-create-user) command. Please note that the user account you use to log in to the [Databend Cloud console](https://app.databend.com/) cannot be used for connecting to Databend Cloud.
149
149
150
+
## Connecting with BendSQL
151
+
152
+
BendSQL allows you to connect to both Databend Cloud and self-hosted Databend instances.
153
+
154
+
### Customize Connections with a DSN
155
+
156
+
A DSN (Data Source Name) is a simple yet powerful way to configure and manage your Databend connection in BendSQL using a single URI-style string. This method allows you to embed your credentials and connection settings directly into your environment, streamlining the connection process.
The best practice for connecting to Databend Cloud is to obtain your DSN from Databend Cloud and export it as an environment variable. To obtain your DSN:
205
+
206
+
1. Log in to Databend Cloud and click **Connect** on the **Overview** page.
207
+
208
+
2. Select the database and warehouse you want to connect to.
209
+
210
+
3. Your DSN will be automatically generated in the **Examples** section. Below the DSN, you'll find a BendSQL snippet that exports the DSN as an environment variable named `BENDSQL_DSN` and launches BendSQL with the correct configuration. You can copy and paste it directly into your terminal.
Copy file name to clipboardExpand all lines: docs/en/tutorials/connect/connect-to-databend-bendsql.md
+57-18Lines changed: 57 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,53 +7,92 @@ slug: /
7
7
import StepsWrap from '@site/src/components/StepsWrap';
8
8
import StepContent from '@site/src/components/Steps/step-content';
9
9
10
-
In this tutorial, we will guide you through the process of connecting to a self-hosted Databend instance using BendSQL as the user `root`.
10
+
In this tutorial, we will guide you through the process of connecting to a self-hosted Databend instance using BendSQL.
11
11
12
12
<StepsWrap>
13
13
<StepContentnumber="1">
14
14
15
15
### Before You Start
16
16
17
+
- Ensure that [Docker](https://www.docker.com/) is installed on your local machine, as it will be used to launch Databend.
17
18
- Ensure that BendSQL is installed on your machine. See [Installing BendSQL](/guides/sql-clients/bendsql/#installing-bendsql) for instructions on how to install BendSQL using various package managers.
18
-
- Ensure that your Databend instance has started up successfully.
19
-
- In this tutorial, you will use the `root` account to connect to Databend. During deployment, uncomment the following lines in the [databend-query.toml](https://github.com/databendlabs/databend/blob/main/scripts/distribution/configs/databend-query.toml) configuration file to select this account:
20
-
21
-
```sql title="databend-query.toml"
22
-
[[query.users]]
23
-
name ="root"
24
-
auth_type ="no_password"
25
-
```
26
19
27
20
</StepContent>
28
21
<StepContentnumber="2">
29
22
30
-
### Launch BendSQL
23
+
### Start Databend
31
24
32
-
To launch BendSQL, enter `bendsql` directly into your terminal or command prompt.
25
+
Run the following command in your terminal to launch a Databend instance:
33
26
34
-
:::note
35
-
The command `bendsql` launches and connects BendSQL to the local Databend at 127.0.0.1 using the `root` user without requiring a password. If you wish to connect to a local Databend with a different user, such as 'eric' with the password 'abc123', use the command `bendsql --user eric --password abc123`. To view all available arguments and their default values, type `bendsql --help`.
This command starts a Databend instance locally in a Docker container with the following connection info:
36
+
37
+
- Host: `127.0.0.1`
38
+
- Port: `8000`
39
+
- User: `eric`
40
+
- Password: `abc123`
39
41
40
42
</StepContent>
41
43
<StepContentnumber="3">
42
44
45
+
### Launch BendSQL
46
+
47
+
Once the Databend instance is running, you can connect to it using BendSQL. Open a terminal and use the following command to connect:
48
+
49
+
```bash
50
+
bendsql --host 127.0.0.1 --port 8000 --user eric --password abc123
51
+
```
52
+
53
+
This will connect to Databend using the HTTP API at `127.0.0.1:8000` with the user `eric` and the password `abc123`. After running this command, you should see a successful connection message, like the one below:
54
+
55
+
```bash
56
+
Welcome to BendSQL 0.24.7-ff9563a(2024-12-27T03:23:17.723492000Z).
57
+
Connecting to 127.0.0.1:8000 as user eric.
58
+
Connected to Databend Query v1.2.725-nightly-25ee2d6e65(rust-1.88.0-nightly-2025-04-16T13:54:25.363718584Z)
59
+
Loaded 1432 auto complete keywords from server.
60
+
Started web server at 127.0.0.1:8080
61
+
```
62
+
63
+
</StepContent>
64
+
<StepContentnumber="4">
65
+
43
66
### Execute Queries
44
67
45
68
Once connected, you can execute SQL queries in the BendSQL shell. For instance, type `SELECT NOW();` to return the current time:
0 commit comments