Connect to a CockroachCloud Free (beta) Cluster

This page shows you how to connect to your CockroachCloud Free (beta) cluster.

Note:

CockroachCloud Free is currently in beta. For information about its limitations, see CockroachCloud Free (beta) FAQs.

Before you start

Step 1. Select a connection method

  1. In the top right corner of the CockroachCloud Console, click the Connect button.

    The Connection info modal displays on the Step 2. Connect > Command Line subtab.

  2. (Optional) To configure your connection information, click Go Back:

    • Select the SQL User you want to connect with.
    • Select the Database you want to connect to.
    • Click Next.
  3. Select a connection method (the instructions in Step 2 below will adjust accordingly):

Step 2. Connect to your cluster

To connect to your cluster with the built-in SQL client:

  1. Click the name of the cc-ca.crt to download the CA certificate to your local machine.

    Alternatively, you can set sslmode=require. This is less secure than using a CA certificate and should not be used with sensitive data.

  2. Create a certs directory on your local machine:

    icon/buttons/copy
    $ mkdir certs
    
  3. Move the downloaded cc-ca.crt file to the certs directory:

    icon/buttons/copy
    $ mv /path/to/cc-ca.crt /path/to/certs
    

    For example:

    icon/buttons/copy
    $ mv /Users/maxroach/Downloads/cc-ca.crt /Users/maxroach/certs
    
  4. If you have not done so already, install the CockroachDB binary.

  5. Copy the cockroach sql command and connection string provided in the Console, which will be used in the next step (and to connect to your cluster in the future).

  6. In your terminal, enter the copied cockroach sql command and connection string to start the built-in SQL client.

    Be sure to replace the <your_certs_ directory> placeholder with the path to the certs directory you created earlier.

  7. Enter the SQL user's password and hit enter.

    Note:

    If you forget your SQL user's password, a Console Admin can change the password on the SQL Users page.

    You are now connected to the built-in SQL client, and can now run CockroachDB SQL statements.

To connect to your cluster with your application, use the connection string provided in the Console::

  1. Click the name of the cc-ca.crt to download the CA certificate to your local machine.
  2. Create a certs directory on your local machine:

    icon/buttons/copy
    $ mkdir certs
    
  3. Move the downloaded cc-ca.crt file to the certs directory:

    icon/buttons/copy
    $ mv /path/to/cc-ca.crt /path/to/certs
    

    For example:

    icon/buttons/copy
    $ mv /Users/maxroach/Downloads/cc-ca.crt /Users/maxroach/certs
    
  4. Copy the connection string provided in the Console, which will be used to connect your application to CockroachCloud Free (beta).

  5. Add your copied connection string to your application code.

    Be sure to replace the <your_certs_ directory> placeholder with the path to the certs directory you created earlier.

    Note:

    If you forget your SQL user's password, a Console Admin can change the password on the SQL Users page.

For examples, see the following:

To connect to your cluster with a CockroachDB-compatible tool, use the connection parameters provided in the Console.

What's next

YesYes NoNo