Thursday, 27 November 2014

How to connect to Hadoop Hive using Beeline?

How to connect to Hadoop Hive using Beeline?

 Apache Beeline is a hive command line client that can be used to connect to Hive server and execute HiveSQL,etc. Beeline uses JDBC to connect.

Sample beeline command to connect to hive server is shown below:

localhost> beeline

beeline> !connect jdbc:hive2://localhost:10000
scan complete in 8ms
Connecting to jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: admin
Enter password for jdbc:hive2://localhost:10000:
Connected to: Apache Hive (version 0.12.0-cdh5.1.2)
Driver: Hive JDBC (version 0.12.0-cdh5.1.2)
0: jdbc:hive2://localhost:1000> show databases;
| database_name  |
| sample         |
| default    |
| employee        |
| operational       |
| test_hive_db   |
5 rows selected (0.52 seconds)
jdbc:hive2://localhost:1000> use test_hive_db;

jdbc:hive2://localhost:1000>select * from employee;

Check the link below to load files to hive: 

To truncate apache hive tables and delete files from hdfs:

More details about beeline is in the below link: