> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usedatabrain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CockroachDB

### Getting Started with CockroachDB Source Configuration

### Requirements:

* Active **CockroachDB** cluster (Self-hosted or CockroachDB Cloud).
* Allow connections from Databrain to your CockroachDB cluster.
* Ensure your CockroachDB user has sufficient read permissions.
* Choose the Databrain Workspace to which you wish to connect the data.

For details on setting up IP whitelisting and secure connectivity, refer to:

<Card title="Allow Access to our IP" icon="arrow-right" href="https://docs.usedatabrain.com/guides/datasources/allow-access-to-our-ip" />

### Setup Guide:

1. **Ensure Database Accessibility:**
   * Ensure your CockroachDB cluster is active and accessible from the machine running Databrain.
   * Accessibility depends on:
     * Network rules / firewall settings
     * CockroachDB Cloud IP allowlisting (if using managed cloud)
     * User privileges
   * The easiest way to verify connectivity is by using the **Authenticate** button in the Databrain connection UI after filling in the details.

2. **Grant Necessary Permissions:**
   * Databrain requires:
     * Read access on tables
     * Access to metadata (information\_schema)
     * Usage on schema

Run the following:

```sql theme={"dark"}
-- Grant USAGE on schema
GRANT USAGE ON SCHEMA schema_name TO username;

-- Grant SELECT on all existing tables
GRANT SELECT ON ALL TABLES IN SCHEMA schema_name TO username;

-- Grant SELECT on future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
GRANT SELECT ON TABLES TO username;
```

Replace `schema_name` and `username` with your actual values.

3. **Fill Up Connection Info:**

   Provide the following details in the Databrain UI:

   * **Integration Name:** Pick a name to help you identify this source in Databrain (e.g., CockroachDB – Production).
   * **Host:** Hostname of the CockroachDB cluster (Example: free-tier.gcp-us-central1.cockroachlabs.cloud)
   * **Port:** `26257` (Default CockroachDB SQL port) Note: Some managed environments may expose 5432 for Postgres compatibility.
   * **Database Name:** Name of the database you want to sync.
   * **Username:** CockroachDB user with read access.
   * **Password:** Password associated with the username.
   * **Schemas:** Defaults to `public`. Provide a comma-separated list (case sensitive) if syncing from multiple schemas.
   * **Encryption:** CockroachDB **requires secure connections (TLS/SSL)** in most deployments.
   * **SSL Mode:** Enable SSL Mode if:
     * You are using CockroachDB Cloud
     * TLS is enforced in your cluster (default in most setups)
     * If your cluster enforces secure transport, SSL Mode must be enabled in Databrain.
   * **SSH Tunnel (If Required):** If your CockroachDB cluster is inside a private network:
     * **SSH Host:** SSH endpoint of the bastion/jump server
     * **SSH Port:** 22
     * **Username:** SSH username
     * **Private Key:** Private key used for SSH authentication
     * **Ensure:**
       * Databrain IP is whitelisted
       * The SSH server can access the CockroachDB cluster internally

### Permissions Checklist:

* Whitelisted Databrain IP
* **USAGE** on schema
* **SELECT** on tables
* Default privileges for future tables (recommended)
* Permission to read `information_schema`

Replace placeholders inside square brackets with actual values when configuring.

### Locating the Configuration Details in CockroachDB

**Host:**

* For CockroachDB Cloud: Available in your cluster connection string.
* For self-hosted: IP address or DNS of the CockroachDB node/load balancer.
* You can find it in:
  * CockroachDB Cloud console → Connect → SQL Connection string

**Port:**

* Default CockroachDB SQL port: `26257`
* Check your cluster configuration if customized.

**Database Name:**

* Connect using:

```sql theme={"dark"}
SHOW DATABASES;
```

**Username:**

* List users:

```sql theme={"dark"}
SHOW USERS;
```

* Or consult your database administrator.

**Password:**

* CockroachDB does not display passwords.
* If forgotten, reset it:

```sql theme={"dark"}
ALTER USER username WITH PASSWORD 'new_password';
```

**Schemas:**

* List schemas:

```sql theme={"dark"}
SHOW SCHEMAS FROM database_name;
```

**SSL Mode:**

* Check cluster settings:

```sql theme={"dark"}
SHOW CLUSTER SETTING server.ssl.enabled;
```

* In CockroachDB Cloud, SSL is enabled by default.
