The following examples demonstrate how to use Beeline to connect to Hive for all possible variations of these modes:
Note | |
---|---|
Documentation for the |
Embedded Client
Use the following syntax to connect to Hive from Beeline in embedded mode:
!connect jdbc:hive2://
Remote Client with HiveServer2 TCP Transport Mode and SASL Authentication
Use the following syntax to connect to HiveServer2 in TCP mode from a remote Beeline client:
!connect jdbc:hive2://<host>:<port>/<db>
The default port for HiveServer2 in TCP mode is 10000
.
db
is the name of the database to which you want to connect.
Remote Client with HiveServer2 TCP Transport Mode and NoSASL Authentication
Clients must explicitly specify the authentication mode in their connection string when HiveServer2 runs in NoSASL mode:
!connect jdbc:hive2://<host>:<port>/<db>;auth=noSasl hiveuser pass org.apache.hive.jdbc.HiveDriver
Important | |
---|---|
If users forget to include |
Remote Client with HiveServer2 HTTP Transport Mode
Use the following syntax to connect to HiveServer2 in HTTP mode from a remote Beeline client:
!connect jdbc:hive2://<host>:<port>/<db>?hive.server2.transport.mode=http;hive.server2.thrift.http.path=<http_endpoint>
Remote Client with HiveServer2 in Secure Cluster
Use the following syntax to connect to HiveServer2 in a secure cluster from a remote Beeline client:
!connect jdbc:hive2://<host>:<port>/<db>;principal=<Server_Principal_of_HiveServer2>
Note | |
---|---|
The Beeline client must have a valid Kerberos ticket in the ticket cache before attempting to connect. |