Steps to Connect to Hive Using Beeline CLI

  • Post author:
  • Post last modified:February 28, 2018
  • Post category:BigData
  • Reading time:3 mins read

Beeline is a JDBC client that is based on the SQLLine CLI. HiveServer2 supports a command shell Beeline that works with HiveServer2. In this article, we will check how to connect to Hive using Beeline CLI and see some examples to execute HiveQL scripts.

Connect to Hive Using Beeline CLI

Connect to Hive Using Beeline CLI

Beeline works on both standalone mode (embedded mode) as well as remote mode. Standalone more or embedded mode, it executes embedded Hive like Hive CLI, and you can use remote mode to connect separate hiveserver2 over thrift.

Read:

Beeline CLI Embedded Mode

Running Beeline client tools with embedded servers is a convenient way to test your query or debug a problem in your HiveQL query. This mode is most commonly used by the developer to test their HiveQL query for syntax error before running it on Hive2 server. Below is the connection string that you can use for Beeline CLI embedded mode:

beeline -u jdbc:hive2://

https://gist.github.com/8eeea4032466509de513a2273e838219

Alternative ways to connect to Hive

Beeline supports connecting to Hive server using !connect option. You just have to provide Hive2 server jdbc connection to the !connect. Below is the syntax and example:

beeline> !connect jdbc:hive2://

https://gist.github.com/3a82fd6ccfb02fe8d5659e06fe310478

Once you execute above command, Beeline enters interactive shell mode, in which queries and commands against the embedded HiveServer2 instance can be executed.

Beeline CLI Remote Mode

You can connect to remote hiveserver2 server using Beeline. Beeline Remote mode supports authentication with LDAP and Kerberos. It also supports encryption with SSL. Beeline remote mode is used to connect to Hive server from other Linux host machine. You can execute the queries on Hive server from remote host machine.

Below is the connection string that you can use for Beeline CLI remote mode:

https://gist.github.com/a5c4d140e8e516902f6a3a21bd84c0a1