All Products
Search
Document Center

E-MapReduce:Use the CLI to connect to Presto

Last Updated:Mar 26, 2026

Use the Presto command-line interface (CLI) to connect to a Presto cluster and run SQL queries against your data.

Prerequisites

Before you begin, make sure you have:

  • An E-MapReduce (EMR) cluster of V3.45.0, V5.11.0, or a later minor version with the Presto service deployed. For more information, see Create a cluster.

Common clusters

Note

A common cluster is one created without Kerberos Authentication enabled.

  1. Log on to the cluster over SSH. For more information, see Log on to a cluster.

  2. Open the Presto CLI:

    presto --server master-1-1:8889

    A successful connection displays the presto> prompt. Run help to see all supported commands, or quit; to exit.

  3. Explore available data sources before running queries. If you don't know which catalogs and schemas are available, run the following commands:

    -- List all catalogs (data sources)
    show catalogs;
    
    -- List schemas in a catalog
    show schemas from <catalog>;
    
    -- Set a default catalog and schema to avoid typing the full path each time
    use <catalog>.<schema>;

    You can also view all catalogs on the Configure tab of the Presto service page in the EMR console.

  4. Query table data:

    Parameter Description
    <catalog> The data source to connect to
    <schema> The database to query
    <table> The table to query
    select * from <catalog>.<schema>.<table>;

    For example, to query the test table in the default Hive database:

    select * from hive.default.test;
  5. (Optional) Exit the Presto CLI:

    quit;

High-security clusters

Note

A high-security cluster is one created with Kerberos Authentication enabled.

Important

High-security clusters are accessible only over HTTPS. The HTTP port 8889 is disabled — http-server.http.port is overwritten by http-server.https.port. Use HTTPS port 7779 instead.

  1. Log on to the cluster over SSH. For more information, see Log on to a cluster.

  2. Open the Presto CLI with Kerberos authentication:

    presto --server https://${FQDN}:7779 \
      --krb5-config-path /etc/krb5.conf \
      --keystore-path /etc/emr/presto-conf/keystore \
      --keystore-password ${pwd} \
      --krb5-keytab-path /etc/emr/presto-conf/presto.keytab \
      --krb5-principal presto/${FQDN}@${REALM} \
      --krb5-remote-service-name presto \
      --user presto/${FQDN}

    The following table describes the parameters you need to supply:

    Parameter Description
    ${FQDN} The fully qualified domain name (FQDN) of the master-1-1 node, in the format master-1-1.c-xxxxxxx.cn-xxxxxx.emr.aliyuncs.com. Run hostname -f to get the value.
    --krb5-config-path The path to the Kerberos configuration file. Fixed value: /etc/krb5.conf. Corresponds to http.authentication.krb5.config in config.properties.
    --keystore-path The path to the TLS keystore. Fixed value: /etc/emr/presto-conf/keystore. Corresponds to http-server.https.keystore.path in config.properties.
    --keystore-password The keystore password. Corresponds to http-server.https.keystore.key in config.properties. Run the following command on the master-1-1 node to get the value: awk -F= '/http-server.https.keystore.key/{print $2}' ${PRESTO_CONF_DIR}/config.properties
    --krb5-keytab-path The path to the Kerberos keytab file. Fixed value: /etc/emr/presto-conf/presto.keytab. Corresponds to http.server.authentication.krb5.keytab in config.properties.
    ${REALM} The Kerberos realm. Unlike the Kerberos realm for Trino, the Kerberos realm for Presto is not stored in the Presto configuration file. Check /etc/krb5.conf for the value — in EMR, the format is EMR.C-XXXXXX.COM.
    --krb5-remote-service-name Fixed value: presto. Corresponds to http.server.authentication.krb5.service-name in config.properties.
  3. Query table data:

    select * from <catalog>.<schema>.<table>;

    For parameter descriptions and examples, see step 4 in Common clusters.

  4. (Optional) Exit the Presto CLI:

    quit;

What's next

Use Java Database Connectivity (JDBC) to connect to Presto for querying, analyzing, and processing complex data, or to integrate query results into Java applications. For more information, see Use JDBC.