---
sidebar_position: 3
title: "Install and connect with the DuckDB CLI"
sidebar_label: DuckDB CLI
description: Learn to connect and query databases using MotherDuck from the DuckDB CLI
hide_title: true
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import DownloadLink from '@site/src/components/DownloadLink';
import OSTabLabel from '@site/src/components/OSTabLabel';
import Versions from '@site/src/components/Versions';
import DuckDBCliTerminalDemo from '@site/src/components/DuckDBCliTerminalDemo';

# DuckDB CLI

## Installation

:::note
MotherDuck supports DuckDB <Versions region="us-east-1" bound="max" />. In **US East (N. Virginia) -** `us-east-1`, MotherDuck is compatible with client versions <Versions region="us-east-1" bound="min" /> through <Versions region="us-east-1" bound="max" />. In **US West (Oregon) -** `us-west-2`, MotherDuck supports client versions <Versions region="us-west-2" bound="min" /> through <Versions region="us-west-2" bound="max" />. In **Europe (Frankfurt) -** `eu-central-1`, MotherDuck supports client versions <Versions region="eu-central-1" bound="min" /> through <Versions region="eu-central-1" bound="max" />.
:::

Download and install the DuckDB binary, depending on your operating system.

<Tabs groupId="os">
<TabItem value="wd" label={<OSTabLabel os="windows" label="Windows" />}>

1. Download the 64-bit Windows binary <DownloadLink region="us-east-1" bound="max" os="windows-amd64" />
2. Extract the zip file.

</TabItem>
<TabItem value="mac" label={<OSTabLabel os="macos" label="macOS" />}>

The recommended way to install the CLI is with the MotherDuck install script:

### Install with bash

```bash
curl -s https://install.motherduck.com | sh
```

</TabItem>
<TabItem value="linux" label={<OSTabLabel os="linux" label="Linux" />}>

1. Download the Linux binary:
    - For 64-bit, download the binary <DownloadLink region="us-east-1" bound="max" os="linux-amd64" />
    - For arm64/aarch64, download the binary <DownloadLink region="us-east-1" bound="max" os="linux-aarch64" />
2. Extract the zip file.

</TabItem>
</Tabs>

For more information, see the [DuckDB installation documentation](https://duckdb.org/docs/installation/).

## Try it

Walk through starting DuckDB, attaching MotherDuck, and running your first query in the playground below. Each step explains what happens before you press Enter, so you can preview the full flow before running it on your machine.

<DuckDBCliTerminalDemo />

## Step by step

### Start the DuckDB CLI

After installing, start DuckDB from your terminal:

```sh
duckdb
```

DuckDB opens an in-memory database by default, so any tables you create won't persist when you exit. Pass a filename to open or create a persistent local database:

```sh
duckdb mydatabase.duckdb
```


### Connect to MotherDuck

From inside the DuckDB CLI, attach MotherDuck:

```sql
ATTACH 'md:';
```

DuckDB downloads the signed MotherDuck extension and opens your default browser to authenticate. Follow the instructions in the terminal.

To list your MotherDuck databases and confirm the connection, run:

```sql
SHOW DATABASES;
```

You can query local DuckDB data and MotherDuck databases from the same session.

For more on persisting your authentication credentials, see [Authenticating to MotherDuck](/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/authenticating-to-motherduck.md).

:::tip
You can also connect to MotherDuck directly when starting DuckDB:

```bash
duckdb "md:"
```

:::

:::note Manual extension update
When MotherDuck releases a new extension version you can force-reinstall the extension from the CLI.

```sh
FORCE INSTALL motherduck;
```

:::

### Open the MotherDuck UI from the CLI

Launch the MotherDuck UI from your terminal:

```bash
duckdb -ui
```

If you're already in a DuckDB session, run `CALL start_ui();` instead.


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/getting-started/interfaces/connect-query-from-duckdb-cli/",
  "page_title": "Install and connect with the DuckDB CLI",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
