@@ -13,28 +13,176 @@ Requirements
1313The CLI requires a Java virtual machine available on the path.
1414It can be used with Java version 8 and higher.
1515
16+ The CLI uses the :doc: `Trino client REST API
17+ </develop/client-protocol>` over HTTP/HTTPS to communicate with the
18+ coordinator on the cluster.
19+
1620Installation
1721------------
1822
19- Download :maven_download: `cli `, rename it to ``trino ``,
20- make it executable with ``chmod +x ``, then run it:
23+ Download :maven_download: `cli `, rename it to ``trino ``, make it executable with
24+ ``chmod +x ``, and run it to show the version of the CLI:
25+
26+ .. code-block :: text
27+
28+ ./trino --version
29+
30+ Run the CLI with ``--help `` or ``-h `` to see all available options.
31+
32+ Running the CLI
33+ ---------------
34+
35+ The minimal command to start the CLI in interactive mode specifies the URL of
36+ the coordinator in the Trino cluster:
37+
38+ .. code-block :: text
39+
40+ ./trino --server http://trino.example.com:8080
41+
42+ If successful, you will get a prompt to execute commands. Use the ``help ``
43+ command to see a list of supported commands. Use the ``clear `` command to clear
44+ the terminal. To stop and exit the CLI, run ``exit `` or ``quit ``.:
45+
46+ .. code-block :: text
47+
48+ trino> help
49+
50+ Supported commands:
51+ QUIT
52+ EXIT
53+ CLEAR
54+ EXPLAIN [ ( option [, ...] ) ] <query>
55+ options: FORMAT { TEXT | GRAPHVIZ | JSON }
56+ TYPE { LOGICAL | DISTRIBUTED | VALIDATE | IO }
57+ DESCRIBE <table>
58+ SHOW COLUMNS FROM <table>
59+ SHOW FUNCTIONS
60+ SHOW CATALOGS [LIKE <pattern>]
61+ SHOW SCHEMAS [FROM <catalog>] [LIKE <pattern>]
62+ SHOW TABLES [FROM <schema>] [LIKE <pattern>]
63+ USE [<catalog>.]<schema>
64+
65+ You can now run SQL statements. After processing, the CLI will show results and
66+ statistics.
67+
68+ .. code-block :: text
69+
70+ trino> SELECT count(*) FROM tpch.tiny.nation;
71+
72+ _col0
73+ -------
74+ 25
75+ (1 row)
76+
77+ Query 20220324_213359_00007_w6hbk, FINISHED, 1 node
78+ Splits: 13 total, 13 done (100.00%)
79+ 2.92 [25 rows, 0B] [8 rows/s, 0B/s]
80+
81+ As part of starting the CLI, you can set the default catalog and schema. This
82+ allows you to query tables directly without specifying catalog and schema.
83+
84+ .. code-block :: text
85+
86+ ./trino --server http://trino.example.com:8080 --catalog tpch --schema tiny
87+
88+ trino:tiny> SHOW TABLES;
89+
90+ Table
91+ ----------
92+ customer
93+ lineitem
94+ nation
95+ orders
96+ part
97+ partsupp
98+ region
99+ supplier
100+ (8 rows)
101+
102+ You can also set the default catalog and schema with the :doc: `/sql/use `
103+ statement.
21104
22105.. code-block :: text
23106
24- ./trino --server localhost:8080 --catalog hive --schema default
107+ trino> USE tpch.tiny;
108+ USE
109+ trino:tiny>
25110
26- Run the CLI with the ``--help `` option to see the available options.
111+ Many other options are available to further configure the CLI in interactive
112+ mode:
27113
28- The CLI uses the HTTP protocol and the
29- :doc: `Trino client REST API </develop/client-protocol >` to communicate
30- with Trino.
114+ .. list-table ::
115+ :widths: 40, 60
116+ :header-rows: 1
117+
118+ * - Option
119+ - Description
120+ * - ``--catalog ``
121+ - Sets the default catalog. You can change the default catalog and schema
122+ with :doc: `/sql/use `.
123+ * - ``--client-info ``
124+ - Adds arbitrary text as extra information about the client.
125+ * - ``--client-request-timeout ``
126+ - Sets the duration for query processing, after which, the client request is
127+ terminated. Defaults to ``2m ``.
128+ * - ``--client-tags ``
129+ - Adds extra tags information about the client and the CLI user. Separate
130+ multiple tags with commas. The tags can be used as input for
131+ :doc: `/admin/resource-groups `.
132+ * - ``--debug ``
133+ - Enables display of debug information during CLI usage for
134+ :ref: `cli-troubleshooting `. Displays more information about query
135+ processing statistics.
136+ * - ``--disable-compression ``
137+ - Disables compression of query results.
138+ * - ``--editing-mode ``
139+ - Sets key bindings in the CLI to be compatible with VI or
140+ EMACS editors. Defaults to ``EMACS ``.
141+ * - ``--http-proxy ``
142+ - Configures the URL of the HTTP proxy to connect to Trino.
143+ * - ``--network-logging ``
144+ - Configures the level of detail provided for network logging of the CLI.
145+ Defaults to ``NONE ``, other options are ``BASIC ``, ``HEADERS ``, or
146+ ``BODY ``.
147+ * - ``--password ``
148+ - Prompts for a password. Use if your Trino server requires password
149+ authentication. You can set the ``TRINO_PASSWORD `` environment variable
150+ with the password value to avoid the prompt. For more information, see :ref: `cli-username-password-auth `.
151+ * - ``--schema ``
152+ - Sets the default schema. You can change the default catalog and schema
153+ with :doc: `/sql/use `.
154+ * - ``--server ``
155+ - The HTTP/HTTPS address and port of the Trino coordinator. The port must be
156+ set to the port the Trino coordinator is listening for connections on.
157+ Trino server location defaults to ``http://localhost:8080 ``.
158+ * - ``--session ``
159+ - Sets one or more :ref: `session properties
160+ <session-properties-definition>`. Property can be used multiple times with
161+ the format ``session_property_name=value ``.
162+ * - ``--socks-proxy ``
163+ - Configures the URL of the SOCKS proxy to connect to Trino.
164+ * - ``--source ``
165+ - Specifies the name of the application or source connecting to Trino.
166+ Defaults to ``trino-cli ``. The value can be used as input for
167+ :doc: `/admin/resource-groups `.
168+ * - ``--timezone ``
169+ - Sets the time zone for the session using the `time zone name
170+ <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> `_. Defaults
171+ to the timezone set on your workstation.
172+ * - ``--user ``
173+ - Sets the username for :ref: `cli-username-password-auth `. Defaults to your
174+ operating system username. You can override the default username,
175+ if your cluster uses a different username or authentication mechanism.
176+
177+ .. _cli-tls :
31178
32179TLS/HTTPS
33180---------
34181
35182Trino is typically available with an HTTPS URL. This means that all network
36183traffic between the CLI and Trino uses TLS. :doc: `TLS configuration
37- </security/tls>` is common, since it is a requirement for any authentication.
184+ </security/tls>` is common, since it is a requirement for :ref: `any
185+ authentication <cli-authentication>`.
38186
39187Use the HTTPS URL to connect to the server:
40188
@@ -46,36 +194,58 @@ The recommended TLS implementation is to use a globally trusted certificate. In
46194this case, no other options are necessary, since the JVM running the CLI
47195recognizes these certificates.
48196
49- Use ``--help `` to see information about specifying the keystore, truststore, and
50- other authentication details as required.
197+ Use the options from the following table to further configure TLS and
198+ certificate usage:
199+
200+ .. list-table ::
201+ :widths: 40, 60
202+ :header-rows: 1
203+
204+ * - Option
205+ - Description
206+ * - ``--insecure ``
207+ - Skip certificate validation when connecting with TLS/HTTPS (should only be
208+ used for debugging).
209+ * - ``--keystore-path ``
210+ - The location of the Java Keystore file that contains the certificate of
211+ the server to connect with TLS.
212+ * - ``--keystore-password ``
213+ - The password for the keystore. This must match the password you specified
214+ when creating the keystore.
215+ * - ``--keystore-type ``
216+ - Keystore type.
217+ * - ``--truststore-password ``
218+ - The password for the truststore. This must match the password you
219+ specified when creating the truststore.
220+ * - ``--truststore-path ``
221+ - The location of the Java truststore file that will be used to secure TLS.
222+ * - ``--truststore-type ``
223+ - Truststore type.
224+
225+ .. _cli-authentication :
51226
52227Authentication
53228--------------
54229
55230The Trino CLI supports many :doc: `/security/authentication-types ` detailed in
56231the following sections:
57232
233+ .. _cli-username-password-auth :
234+
58235Username and password authentication
59236^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60237
61- Username and password authentication is typically configured in a cluster with
62- the ``PASSWORD `` authentication type.
63-
64- If your Trino server requires password authentication, use the ``--password ``
65- option to have the CLI prompt for a password. If your cluster uses a different
66- username, you can override your username with the ``--user `` option. It defaults
67- to your operating system username.
238+ Username and password authentication is typically configured in a cluster using
239+ the ``PASSWORD `` :doc: `authentication type </security/authentication-types >`,
240+ for example with :doc: `/security/ldap ` or :doc: `/security/password-file `.
68241
69242The following code example connects to the server, establishes your user name,
70243and prompts the CLI for your password:
71244
72- .. code-block :: text
245+ .. code-block :: text
73246
74247 ./trino --server https://trino.example.com --user=myusername --password
75248
76- You can set the ``TRINO_PASSWORD `` environment variable with the password value
77- to avoid the prompt.
78-
79249 .. _cli-external-sso-auth :
80250
81251External authentication - SSO
@@ -134,11 +304,57 @@ JWT authentication
134304To access a Trino cluster configured to use :doc: `/security/jwt `, use the
135305``--access-token=<token> `` option to pass a JWT to the server.
136306
307+ .. _cli-kerberos-auth :
308+
137309Kerberos authentication
138310^^^^^^^^^^^^^^^^^^^^^^^
139311
140- If your cluster is secured with Kerberos authentication, see
141- :doc: `/security/cli `.
312+ In addition to the options that are required when connecting to an unauthorized
313+ Trino coordinator, invoking the CLI with Kerberos support enabled requires a
314+ number of additional command line options. The simplest way to invoke the CLI is
315+ with a wrapper script.
316+
317+ .. code-block :: text
318+
319+ #!/bin/bash
320+
321+ ./trino \
322+ --server https://trino-coordinator.example.com:7778 \
323+ --krb5-config-path /etc/krb5.conf \
324+ --krb5-principal someuser@EXAMPLE.COM \
325+ --krb5-keytab-path /home/someuser/someuser.keytab \
326+ --krb5-remote-service-name trino \
327+ --keystore-path /tmp/trino.jks \
328+ --keystore-password password \
329+ --catalog <catalog> \
330+ --schema <schema>
331+
332+ The following table list the available options for Kerberos authentication:
333+
334+ .. list-table :: CLI options for Kerberos authentication
335+ :widths: 40, 60
336+ :header-rows: 1
337+
338+ * - Option
339+ - Description
340+ * - ``--krb5-config-path ``
341+ - Path to Kerberos configuration files.
342+ * - ``--krb5-credential-cache-path ``
343+ - Kerberos credential cache path.
344+ * - ``--krb5-disable-remote-service-hostname-canonicalization ``
345+ - Disable service hostname canonicalization using the DNS reverse lookup.
346+ * - ``--krb5-keytab-path ``
347+ - The location of the keytab that can be used to authenticate the principal
348+ specified by ``--krb5-principal ``.
349+ * - ``--krb5-principal ``
350+ - The principal to use when authenticating to the coordinator.
351+ * - ``--krb5-remote-service-name ``
352+ - Trino coordinator Kerberos service name.
353+ * - ``--krb5-service-principal-pattern ``
354+ - Remote kerberos service principal pattern (default: ${SERVICE}@${HOST})
355+
356+ See :doc: `/security/cli ` for more information on configuring and using Kerberos
357+ with the CLI.
142358
143359Pagination
144360----------
@@ -160,6 +376,8 @@ press :kbd:`Enter`.
160376By default, you can locate the Trino history file in ``~/.trino_history ``.
161377Use the ``TRINO_HISTORY_FILE `` environment variable to change the default.
162378
379+ .. _cli-output-format :
380+
163381Output Formats
164382--------------
165383
@@ -260,6 +478,8 @@ and displays an error message (which is unaffected by the output format):
260478 Query 20200707_170726_00030_2iup9 failed: line 1:25: Column 'region' cannot be resolved
261479 SELECT nationkey, name, region FROM tpch.sf1.nation LIMIT 3
262480
481+ .. _cli-troubleshooting :
482+
263483Troubleshooting
264484---------------
265485
@@ -286,4 +506,3 @@ To view debug information, including the stack trace for failures, use the
286506 ...
287507 at java.base/java.lang.Thread.run(Thread.java:834)
288508 select count(*) from tpch.tiny.nations
289-
0 commit comments