[Yandex Cloud documentation](../../index.md) > [Yandex WebSQL](../index.md) > [Step-by-step guides](index.md) > Creating a connection

# Creating a connection

In Yandex WebSQL, you can create a [connection](../concepts/index.md#connection) to:

* [Managed database clusters](#connect-cluster) in Yandex Cloud
* [Custom DB installation](#connect-db)

## Connecting to a managed database cluster in Yandex Cloud {#connect-cluster}

In Yandex WebSQL, you can connect to databases in the following clusters:

* [Yandex Managed Service for PostgreSQL](../../managed-postgresql/operations/cluster-list.md)
* [Yandex Managed Service for ClickHouse®](../../managed-clickhouse/operations/cluster-list.md)
* [Yandex Managed Service for MySQL®](../../managed-mysql/operations/cluster-list.md)
* [Yandex Managed Service for Valkey™](../../managed-valkey/operations/cluster-list.md)
* [Yandex StoreDoc](../../storedoc/operations/cluster-list.md)* [Yandex MPP Analytics for PostgreSQL](../../managed-greenplum/operations/cluster-list.md)

Before creating a connection, make sure you have selected the right folder. If you have access to PostgreSQL, ClickHouse®, MySQL®, Greenplum®, Valkey™, or Yandex StoreDoc clusters previously created in that folder, they will automatically appear in the **Yandex Cloud connections** subsection. You will only need to create a connection to the appropriate database in the cluster.


{% note info %}

[Yandex Managed Service for Trino](../../managed-trino/index.md) is at the [Preview](../../overview/concepts/launch-stages.md) stage. Currently, you cannot create connections to Yandex Managed Service for Trino in the Yandex WebSQL interface. However, if the current folder has a Yandex Managed Service for Trino cluster and the user can access it, the connection will be displayed in WebSQL, available for use. 

{% endnote %}


WebSQL uses connections in Yandex MetaData Hub Connection Manager, so all connections configured in Connection Manager are automatically available in WebSQL provided that the user has the appropriate [roles](../../metadata-hub/security/index.md#service-roles).

To create a connection to a Yandex Cloud managed database cluster:

1. Make sure **WebSQL access** is enabled in the cluster settings.
1. Open Yandex WebSQL [**Connections**](https://websql.yandex.cloud).
1. In ![image](../../_assets/console-icons/folder-tree.svg) **Connections**, click ![image](../../_assets/console-icons/square-plus.svg).
1. In the **Database type** field, select the database you need: PostgreSQL, ClickHouse®, MySQL®, Valkey™, Yandex StoreDoc, or Greenplum®.
1. In the **Cluster folder** field, select the folder hosting the required cluster.
1. In the **Cluster** field, select the managed database cluster you want to connect to. 
1. Specify the **Username** you will use to connect to cluster databases.
1. Enter the user **Password**.
1. List the **Databases** you want to connect to. You can only connect to the databases that exist in this cluster. The user you specified must have access to them.
1. Click **Create**.

You can also [create a connection](../../metadata-hub/operations/create-connection.md) to a cluster in Yandex MetaData Hub Connection Manager. This connection will automatically appear in Yandex WebSQL. But DB username, password, and name should be entered manually.

If the connection is successful, you will see the cluster structure in the connection tree. Connections to databases within a single managed database cluster are grouped into an expandable list under the name of that cluster.

## Connecting to a custom DB installation {#connect-db}

To connect to a custom DB installation over the internet:

1. Open Yandex WebSQL [**Connections**](https://websql.yandex.cloud).
1. In ![image](../../_assets/console-icons/folder-tree.svg) **Connections**, click ![image](../../_assets/console-icons/square-plus.svg).
1. In the bottom-left corner of the window that opens, click **External connection**.
1. **Name** the connection.
1. In the **Database type** field, select the database: PostgreSQL, ClickHouse®, MySQL®, Valkey™, MongoDB, Greenplum®, Valkey™, or Yandex StoreDoc.
1. Under **Hosts**, configure the hosts:
    * Specify the database host FQDN and port number for connecting to the database.
    * For ClickHouse®, also specify the Native Protocol port and [shard](../../managed-clickhouse/operations/shards.md#list-shards) name.
    * Optionally, enable TLS.

        If your company has a certification authority (CA), the certificate issued by the CA will be used by default. If the company has no CA, upload the server's TLS certificate.

1. Specify the **Username** you will use to connect to the database.
1. Enter the user **Password**.
1. List the **Databases** you want to connect to. You can only connect to existing databases. The user you specified must have access to them.
1. Click **Create**.

If the connection is successful, you will see the database structure in the connection tree.

_ClickHouse® is a registered trademark of [ClickHouse, Inc](https://clickhouse.com)._