Step 1. Create a free trial cluster
For this tutorial, you will create a 3-node GCP cluster in theus-west2 region.
- If you haven’t already, sign up for a CockroachDB Cloud account.
- Log in to your CockroachDB Cloud account.
- On the Overview page, click Create cluster.
- On the Create Cluster page, select Advanced.
- For Cloud provider, select Google Cloud.
- For Regions & nodes, select
California (us-west)region and 3 nodes.
To create a trial cluster, you can select 3 regions with 3 nodes per region, 9 nodes in total.
- For VPC Peering, use the default selection of Use the default IP range. Click Next: Capacity.
- On the Capacity page, select 4 vCPU for Compute per node and a 35 GiB disk for Storage per node.
You can select up to 9 nodes, 4 vCPUs of compute, and 150 GiB of storage. The trial code will not apply to larger clusters.
- Click Next: Finalize.
- On the Finalize page, enter your credit card details.
You will not be charged until after your free trial expires in 30 days.
- Name the cluster. The cluster name must be 6-20 characters in length, and can include lowercase letters, numbers, and dashes (but no leading or trailing dashes).
- Click Create cluster.
Step 2. Create a SQL user
- In the left navigation bar, click SQL Users.
- Click Add User. The Add User dialog displays.
- Enter a username and click Generate & Save Password.
- Copy the generated password to a secure location, such as a password manager.
- Click Close.
Step 3. Authorize your network
- In the left navigation bar, click Networking.
- Click Add Network. The Add Network dialog displays.
- From the Network dropdown, select Current Network to auto-populate your local machine’s IP address.
- To allow the network to access the cluster’s DB Console and to use the CockroachDB client to access the databases, select the DB Console to monitor the cluster and CockroachDB Client to access the databases checkboxes.
- Click Apply.
Step 4. Connect to the cluster
To download CockroachDB locally and configure it to connect to the cluster with the SQL user you just created, refer to . Make a note of thecockroach sql command provided in the Connect dialog.
Step 5. Use the built-in SQL client
-
In your terminal, use the
cockroach sqlcommand from Step 4. Connect to the cluster to connect to the cluster using the binary you just configured.Where:This connection string contains your password, which will be provided only once. Save it in a secure place (e.g., in a password manager) to connect to your cluster in the future. If you forget your password, you can reset it by going to the SQL Users page for the cluster, found athttps://cockroachlabs.cloud/cluster/<CLUSTER ID>/users.<useris the SQL user. By default, this is your CockroachDB Cloud account username.<cluster-name-<short-idis the short name of your cluster plus the short ID. For example,funny-skunk-3ab.<cluster-idis a unique string used to identify your cluster when downloading the CA certificate. For example,12a3bcde-4fa5-6789-1234-56bc7890d123.<regionis the region in which your cluster is running. If you have a multi-region cluster, you can choose any of the regions in which your cluster is running. For example,aws-us-east-1.<databaseis the name for your database. For example,defaultdb.
-
Enter the SQL user’s password and hit enter.
A welcome message displays:PostgreSQL connection URIs do not support special characters. If you have special characters in your password, you will have to URL encode them (e.g.,
password!should be entered aspassword%21) to connect to your cluster. -
You can now run :
-
To exit the SQL shell:
What’s next?
Learn more:- Use the to connect to your cluster and learn .
- Build a , or for your favorite language.
- Use a local cluster to .
- from which your app will access the cluster.
- Configure every machine from which you want to .
- Review the .

