Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Hive using Beeline

Tags:

I am trying to connect to hive installed in my machine through Beeline client. when I give the 'beeline' command & connect to Hive, the client is asking for user name & password

!connect jdbc:hive2://localhost:10000/default 

I have no idea what is the user name and password I am supposed to give. Do I have to add the credential(user name & password) in some configuration file?

like image 498
Raj Avatar asked Mar 18 '15 02:03

Raj


People also ask

How do I connect to Hive from command line?

Configuring the ConnectionSpecify your username for a proxy user or for the Beeline CLI. Specify your Beeline CLI password. Specify your JDBC Hive host that is used for Hive Beeline. Specify your JDBC Hive port that is used for Hive Beeline.


1 Answers

Accessing HIVE via Beeline:

Starting beeline client

beeline --incremental=true 

Note: The command line option “—incremental=true” is optional, but will extend the amount of time that you can remain idle and not have your connection dropped.

Connecting to hive2 server

!connect jdbc:hive2://silver-server- hive.app.google.com:10000/default 

Note: You will be prompted for your username & password. USE user name and Password

beeline> !connect jdbc:hive2:// silver-server-hive.app.google.com:10000/default scan complete in 3ms Connecting to jdbc:hive2:// silver-server-hive.app.google.com:10000/default Enter username for jdbc:hive2:// silver-server-hive.app.google.com:10000/default:suman Enter password for jdbc:hive2:// silver-server-hive.app.google.com:10000/default: ********* 

Setting Your Queue (if any)

set mapred.job.queue.name=<your queue name>;  

Note: You need to set a queue in order to run queries.

Setting Your Database

USE google_map_data; 

Note: You should be in a database when executing queries.

Reconnecting an inactive session

!reconnect jdbc:hive2:// silver-server-hive.app.google.com:10000/default;  

Quitting beeline client

!quit 

Notes:

  • Loading beeline, the URL and providing your username & password in one command:

beeline -u jdbc:hive2:// silver-server-hive.app.google.com:10000\  -n <yourname> -p <yourpassword> --incremental=true** 

Basic Beeline Queries

Beeline supports a rich set of SQL query functions.

Getting Information About Data

SHOW DATABASES; USE <database>;  SHOW TABLES; DESC <table>; DESC FORMATTED <table>; 

Simple limited select statements

SELECT * FROM google_map_city limit 25; 
like image 78
Suman Avatar answered Sep 29 '22 19:09

Suman