Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for Trino
  • Getting started
    • All guides
    • Information about existing clusters
    • Creating a cluster
    • Updating a cluster
    • Stopping and starting a cluster
    • Connecting to a cluster
    • Deleting a cluster
  • Quotas and limits
  • Access management
  • Pricing policy
  • Release notes

In this article:

  • Getting an SSL certificate
  • Command line tools
  • Trino CLI
  • Connecting from graphical IDEs
  • WebSQL
  • Examples of connection strings
  • Python
  • Java
  • Node.js
  1. Step-by-step guides
  2. Connecting to a cluster

Connecting to a Trino cluster

Written by
Yandex Cloud
Updated at May 13, 2025
  • Getting an SSL certificate
  • Command line tools
    • Trino CLI
  • Connecting from graphical IDEs
  • WebSQL
  • Examples of connection strings
    • Python
    • Java
    • Node.js

You can connect to a Managed Service for Trino cluster:

  • Over the internet using an SSL connection

  • From Yandex Cloud VMs located in the same cloud network

Getting an SSL certificateGetting an SSL certificate

To use an encrypted connection, get an SSL certificate:

Linux (Bash)/macOS (Zsh)
Windows (PowerShell)
mkdir -p ~/.trino && \
wget "https://storage.yandexcloud.net/cloud-certs/CA.pem" \
     --output-document ~/.trino/root.crt && \
chmod 0655 ~/.trino/root.crt

The certificate will be saved to the ~/.trino/root.crt file.

mkdir $HOME\.trino; curl.exe -o $HOME\.trino\root.crt https://storage.yandexcloud.net/cloud-certs/CA.pem

The certificate will be saved to the $HOME\.trino\root.crt file.

To use graphical IDEs, save a certificate to a local folder and specify the path to it in the connection settings.

Command line toolsCommand line tools

Trino CLITrino CLI

If you do not have the Trino CLI yet, install it using the guide on the official Trino website.

To connect to an Managed Service for Trino cluster:

  1. Create an IAM token and put it to the TRINO_PASSWORD environment variable:

    export TRINO_PASSWORD=$(yc iam create-token)
    

    This IAM token in TRINO_PASSWORD will be your password to the Managed Service for Trino cluster. To enable it, specify the --password flag upon connection.

  2. Connect to the Managed Service for Trino cluster:

    ./trino <coordinator_URL> --user iam --password
    

    You can copy the coordinator URL and paste it to the Coordinator field on the Trino overview page in the management console.

Connecting from graphical IDEsConnecting from graphical IDEs

Before connecting:

  1. Create an IAM token:

    yc iam create-token
    
  2. Save the token. You will use it as a password for the connection.

DataGrip
DBeaver
  1. Create a data source:
    1. Select File → New → Data Source → Trino.
    2. Enter a name for the data source.
    3. Specify the connection parameters on the General tab:
      • Host: c-<cluster_ID>.trino.yandexcloud.net.
      • Port: 443.
      • User: iam.
      • Password: Previously created IAM token.
    4. On the SSH/SSL tab:
      1. Enable the Use SSL setting.
      2. In the CA file field, specify the path to the file with an SSL certificate for the connection.
  2. Click Test Connection to test the connection. If the connection is successful, you will see the connection status and information about the DBMS and driver.
  3. Click OK to save the data source.
  1. Create a new DB connection:
    1. In the Database menu, select New connection.
    2. Select Trino from the list.
    3. Click Next.
    4. Specify the connection parameters on the Main tab:
      • Host: c-<cluster_ID>.trino.yandexcloud.net.
      • Port: 443.
      • Under Authentication, specify:
        • Username: iam.
        • Password: Previously created IAM token.
  2. Click Test Connection ... to test the connection. If the connection is successful, you will see the connection status and information about the DBMS and driver.
  3. Click Ready to save the database connection settings.

WebSQLWebSQL

  1. In the management console, open Managed Service for Trino.

  2. Open your Managed Service for Trino cluster.

  3. Navigate to WebSQL.

  4. Click Go to WebSQL.

  5. In the SQL query editor that opens, run the following query:

    SELECT version() AS version;
    

    The response will contain Trino version information.

Examples of connection stringsExamples of connection strings

PythonPython

Before connecting:

  1. Install the dependencies:

    pip3 install trino
    
  2. Create an IAM token and put it to the TOKEN environment variable:

    export TOKEN=$(yc iam create-token)
    
Connecting via SSL
  1. Code example:

    connect.py

    import os
    from contextlib import closing
    from trino.dbapi import connect
    from trino.auth import BasicAuthentication
    
    TIMEOUT = 10
    COORDINATOR_URL = '<coordinator_URL>'
    IAM_TOKEN = os.environ['TOKEN']
    
    def get_version():
        auth = BasicAuthentication(username='iam', password=IAM_TOKEN)
        with closing(connect(host=COORDINATOR_URL, port=443, auth=auth, request_timeout=TIMEOUT)) as conn:
            with closing(conn.cursor()) as cur:
                cur.execute('SELECT version() as version')
                rows = cur.fetchall()
                print(rows[0][0])
    
    if __name__ == "__main__":
        get_version()
    

    You can copy the coordinator URL and paste it to the Coordinator field on the Trino overview page in the management console.

  2. Connecting:

    python3 connect.py
    

JavaJava

Before connecting:

  1. Install the dependencies:

    sudo apt update && sudo apt install --yes openjdk-21-jre maven
    
  2. Create a folder for the Maven project:

    cd ~/ && mkdir -p project/src/main/java/com/example && cd project/
    
  3. Create a configuration file for Maven:

    pom.xml
    <?xml version="1.0" encoding="utf-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.example</groupId>
        <artifactId>app</artifactId>
        <version>0.1.0</version>
        <packaging>jar</packaging>
        <properties>
            <maven.compiler.source>21</maven.compiler.source>
            <maven.compiler.target>21</maven.compiler.target>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
        <dependencies>
            <dependency>
                <groupId>io.trino</groupId>
                <artifactId>trino-jdbc</artifactId>
                <version>469</version>
            </dependency>
        </dependencies>
        <build>
            <finalName>${project.artifactId}-${project.version}</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.7.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <phase>package</phase>
                            <configuration>
                                <descriptorRefs>
                                    <descriptorRef>
                                        jar-with-dependencies</descriptorRef>
                                </descriptorRefs>
                                <archive>
                                    <manifest>
                                        <mainClass>com.example.App</mainClass>
                                    </manifest>
                                </archive>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.4.2</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>com.example.App</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    
    
  4. Create an IAM token and put it to the TOKEN environment variable:

    export TOKEN=$(yc iam create-token)
    
Connecting via SSL
  1. Code example:

    src/main/java/com/example/App.java

    package com.example;
    
    import java.sql.DriverManager;
    import java.util.Properties;
    
    public class App {
        private static final String COORDINATOR_URL = "c-<cluster_ID>.trino.yandexcloud.net";
    
        public static void main(String[] args) {
            String url = String.format("jdbc:trino://%s", COORDINATOR_URL);
            String iamToken = System.getenv("TOKEN");
      
            Properties properties = new Properties();
            properties.setProperty("user", "iam");
            properties.setProperty("password", iamToken);
            properties.setProperty("SSL", "true");
    
            try (var connection = DriverManager.getConnection(url, properties)) {
                var rs = connection.createStatement().executeQuery("SELECT version() as VERSION");
                if (rs.next()) {
                    System.out.println(rs.getString(1));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    
    

    You can get the Managed Service for Trino cluster ID in the management console with the list of Managed Service for Trino clusters in the folder.

  2. Building and connecting:

    mvn clean package && \
    java -jar target/app-0.1.0-jar-with-dependencies.jar
    

Node.jsNode.js

Before connecting:

  1. Install the dependencies:

    sudo apt update && sudo apt install --yes nodejs npm && \
    npm install trino-client
    
  2. Create an IAM token and put it to the TOKEN environment variable:

    export TOKEN=$(yc iam create-token)
    
Connecting via SSL

app.mjs

"use strict";
import {BasicAuth, Trino} from 'trino-client';

const COORDINATOR_URL = '<coordinator_URL>'
let TOKEN = process.env.TOKEN

async function get_version() {
    const trino = Trino.create({server: COORDINATOR_URL,auth: new BasicAuth('iam', TOKEN)});
    const query = await trino.query('SELECT version() as VERSION');
    const queryResult = await query.next()
    console.log(queryResult.value.data[0][0])
}

get_version();

You can copy the coordinator URL and paste it to the Coordinator field on the Trino overview page in the management console.

Connecting:

node app.mjs

Was the article helpful?

Previous
Stopping and starting a cluster
Next
Deleting a cluster
© 2025 Direct Cursus Technology L.L.C.